File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes about GenericServlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "about GenericServlet" Watch "about GenericServlet" New topic

about GenericServlet

Weerawit Maneepongsawat
Ranch Hand

Joined: Apr 11, 2002
Posts: 203
Why GenericServlet is implements ServletConfig
I think at init(ServletConfig) method is received ServletConfig
Is it make sense??

Weerawit<br />SCJP 1.4, SCWCD 1.2, SCWCD 1.4, SCBCD 1.3, SCBCD 5.0, SCMAD 1.0, SCJA 1.0, SCDJWS, SCJD, SCEA, SCDJWS 1.5
Hari babu
Ranch Hand

Joined: Jun 25, 2001
Posts: 208
The configuration parameters initialised by the init(servletConfig) method, but how does the implement servlet classes get handle to the configuration parameters initialized from the init() method. Hence the Generic servlet extends ServletConfig interface
Weerawit Maneepongsawat
Ranch Hand

Joined: Apr 11, 2002
Posts: 203
I think all servlet had hold ServletConfig by use
getSerlvetConfig() method.
Can this code true
ServletConfig config = (ServletConfig) this;
Is it make sense??..
thank for reply..
Tieyi Guo

Joined: Oct 29, 2001
Posts: 15
ServletConfig object is initialized by the container and passed to the servlet so that the servlet can know something about the initial input parameters.
I believe the only reason GenericServlet implements ServletConfig interface is to make an simple API for the developer to access the init parameters and ServletContext. Please notice that there is a method getServletConfig() defined in GenericServlet. After calling that, you can get hold of a ServletConfig object. From there, you can get all init information by calling the 4 methods defined in ServletConfig interface: getInitParameter(String), getInitParameterNames(), getServletContext(), getServletName(). These 4 methods are exposed to developer in GenericServlet API so that the developer can call them directly instead of going through the route of getting a ServletConfig object first.
That is just my understanding. Does this make sense to you guys?
I agree. Here's the link:
subject: about GenericServlet
It's not a secret anymore!