2

I'm updating a regular Servlet to a Spring kind Servlet. To accomplish this I followed these instructions that say I should implement HttpRequestHandler. That's great and works for my Servlet because right now I only call it using POST method.

But now I'm curious about what happens if I want to implement the GET method too. In a regular Servlet I have:

public class MyServlet extends HttpServlet {

protected void processRequest(HttpServletRequest request, HttpServletResponse response) 
...
protected void doGet(HttpServletRequest request, HttpServletResponse response)
...
protected void doPost(HttpServletRequest request, HttpServletResponse response)
...

}

But when implementing HttpRequestHandler I have:

public class MyServlet implements HttpRequestHandler {
...
   public void handleRequest(HttpServletRequest request, HttpServletResponse response)
...
}

Reading the official documentation it says that it only supports POST by default, but couldn't find a way to implement GET. Other answer here gave me an idea of using a Controller that could receive a GET request and then call the HttpRequestHandler, but that didn't seemed very neat to me.

Can anyone tell me if it is possible and how do I do it? If possible reference some docs :)

Community
  • 1
  • 1
Christian Vielma
  • 15,263
  • 12
  • 53
  • 60
  • The documentation says that request handlers normally handle only POST requests, not that it doesn't support GET requests: what happened when you tried it? – Dave Newton May 06 '13 at 18:04

1 Answers1

0

this is just a guess but can't you just use request parameter to determine the method and act accordingly further in handleRequest method?

Den Roman
  • 548
  • 7
  • 10