Prepare Interview

Mock Exams

Make Homepage

Bookmark this page

Subscribe Email Address

Servlets%20Interview%20Questions%20and%20Answers

Question: Can you explain in detail "javax.servlet" package?
Answer:

javax.servlet package has interfaces and classes which define a framework in which servlets can operate. Let's first make a walk through of all the interfaces and methods and its description.

Interfaces in javax.servlet :-
Servlet Interface: This interface has the init( ), service( ), and destroy( ) methods that are called by the server during the life cycle of a servlet. Following are the method in Servlet interface :-

void destroy( ):- Executed when servlet is unloaded from the web server memory.

ServletConfig getServletConfig() :- Returns back a ServletConfig object that contains initialization data.

String getServletInfo( ):- Returns a string describing the servlet.

init method :- Called for first time when the servlet is initialized by the web server.

void service() method :- Called to process a request from a client.

ServletConfig Interface:- This interface is implemented by the servlet container. Servlet can access any configuration data when its loaded. The methods declared by this interface are summarized here: Following are the methods in ServletConfig interface:-

ServletContext getServletContext():- Gives the servlet context.

String getInitParameter(String param):- Returns the value of the initialization parameter named param.

Enumeration getInitParameterNames():- Returns an enumeration of all initialization parameter names.
String getServletName():- Returns the name of the invoking servlet.

rn
Is it helpful? Yes No

Most helpful rated by users:

©2024 WithoutBook