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

getParameter() in GenericServlet

 
Nikhil Jain
Ranch Hand
Posts: 389
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello ranchers,
I was justing going thru the API. I found that the GenericServlet Abstract class has a method for getParameter(String). I just want to know, that when we write request.getParameter(String), does the container call the method from GenericServlet. I am preety confused, because int the doGet(HttpServletRequest, HttpServletResponse), both these are Interfaces, so where is the implementation. ???, I just trying the figure out, how the whole thing works!!, can anyone put some light on it....thanks in advance...
Shashank
 
salil verma
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Shashank
javax.servlet.GenericServlet does not have any function with signature getParameter(String). Although it has one function with signature getInitParameter(java.lang.String name). This function is used to get the init parameter of servlet config. Servlet config parameters are defined in deployment descriptor.

When a browser sends the request to a servler the container creates two Object implementing javax.servlet.http.HttpServletRequest and javax.servlet.http.HttpServetRespose , creates a new thread and calles the service method of servlet passing these parameters.

These same are also passed in doGet(HttpServletRequest request ,HttpServletResponse response) method.
 
Nikhil Jain
Ranch Hand
Posts: 389
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
but we get config values from servletConfig.getInitParameter(java.lang.String name). So the method getInitParameter(java.lang.String name) is called from the servletConfig interface. Then why does Generic Servlet has this method. Am i thinking in right direction??
 
salil verma
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi Shashank
You are thiking in right direction , but have you ever thought the reson of existance of javax.servlet.GenericServlet. This class implements all the functions of javax.servlet.Servlet and javax.servlet.ServletConfig interfaces except servlet(ServletRequest,ServletResponse) method of javax.servlet.Servlet.

That is why this also has same methods as of javax.servlet.Servlet and javax.servlet.ServletConfig.
 
salil verma
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The class declaration of javax.servlet.GenericServlet is

public abstract class GenericServlet
extends java.lang.Object
implements Servlet, ServletConfig, java.io.Serializable

you can understand the same that i wanted to express
 
Nikhil Jain
Ranch Hand
Posts: 389
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks, now I get it...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic