dcsimg

Is there any way to convert "Post" request to "Get" request dynamically in case of JSP, as there is only service method?

Prasad Thammineni

According to the JSP 1.1 spec when a JSP gets compiled it will generate the _jspService() method to handle the request. There is no mechanism available to provide your own _jspService() method, although you can specify the class the generated servlet class needs to extend. When you specify a base class using the <% page extends %> directive you need to comply by some rules. One of them being, the service() method of your base class should call the _jspService() method.

Refer to section 3.2 of the JSP 1.1 specificaition for a detailed example.

Lastly, if you decide not to use your own base class, the generated _jspService() method will handle both GET and POST methods. What I mean is that if you have a JSP page, you can request it from the address bar(GET) or post to it from a FORM. As long as you use the HttpServletRequest.getParameter(s)() methods you can get access to the parameters.