> YourServlet extends javax.servlet.http.HttpServlet, and
> javax.servlet.http.HttpServlet extends javax.servlet.GenericServlet,
> the following is from HttpServlet in jakarta-servletapi-4-src.zip in
> www.Apache.org:
> 
>     ...
>  protected void doPost(HttpServletRequest req, HttpServletResponse resp)
>  throws ServletException, IOException
>  {
>  String protocol = req.getProtocol();
>  String msg = lStrings.getString("http.method_post_not_supported");
>  if (protocol.endsWith("1.1")) {
>      resp.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED, msg);
>  } else {
>      resp.sendError(HttpServletResponse.SC_BAD_REQUEST, msg);
>  }
>  }
>  ...
> 
> it doesn't response anything to the client, so you need to override it
> in YourServlet.

You are right, but this is interesting, I have overriden the "service()" method, which 
in the HttpServlet dispatches a request to an appropriate method. Was it wrong to do 
that? Should I have left "service()" as it was and overriden "doGet()" and "doPost()" 
instead?

In my servlet I didn't particulary care which HTTP method was used to call the 
servlet, I just wanted the parameters of the request and I wanted to process them. I 
realize now that a more strict servlet should pay attention to the HTTP method used to 
call it. So, any comment?

Nix.


Reply via email to