Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

about GenericServlet

 
Weerawit Maneepongsawat
Ranch Hand
Posts: 203
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why GenericServlet is implements ServletConfig
I think at init(ServletConfig) method is received ServletConfig
Is it make sense??
Thank
 
Hari babu
Ranch Hand
Posts: 208
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 203
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
Tieyi
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic