views:

144

answers:

2

In NetBeans 6.7.1, I have made a j2ee project,

In this project I have Servlet that extends HttpServlet,
Of whatever little I know about servlets, they should have a service method however in the class in NetBeans I find only thefollowing methods.

protected void processRequest(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {}
protected void doGet(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {}
protected void doPost(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {}
public String getServletInfo() {}

doGet and doPost in call the processRequest method. Where is the service method?

+2  A: 

A servlet does not need to (re)implement the service() method of the javax.servlet.Servlet or javax.servlet.http.HttpServlet class. Regurgitating from the API doc, the service() method is used to dispatch requests to the doXXX() methods of the servlet. It is already implemented in the HttpServlet class, for the HTTP protocol, and hence there is no need to override it in another servlet relying on the HTTP protocol.

By the way, NetBeans automatically creates the doGet(), doPost(), getServletInfo() and processRequest() methods for convenience, when you create a servlet. It does not mean that the service() method is not available - most servlet programmers do not have to implement the service() method.

Vineet Reynolds
A: 

In my J2EE application I use a servlet, but Netbeans doesn't appears to recongnice the libraries javax.servlet.http.HttpServlet, javax.servlet.http.HttpServletRequest, or javax.servlet.http.HttpServletResponse, is valid to mention that I use Netbena 6.7...how can I fix the problem??????

I guess you have already received your answer to the question you have posted... Even so please choose Web Application Template from the New Project Dialog...
Kevin Boyd