Loading
Servlet Post Get

Java Quick Notes

Refresh Your Java - Before Java Interview

We are Agile, believe in less Documentation - Only Quick notes (Java Interview Questions) of Java/J2ee Read more....


Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet

Go to SiteMap

Q)  How would you make your servlet work for both GET and POST http requests ?


Ans)

If you write a Servlet as shown below that could work fine for both POST as well as GET Http Requests.

public class CommonServlet extends HttpServlet {
        protected void doGet(HttpServletRequest req, HttpServletResponse resp)
                        throws ServletException, IOException {
                doProcess(req, resp);
        }

        protected void doPost(HttpServletRequest req, HttpServletResponse resp)
                        throws ServletException, IOException {
                doProcess(req, resp);
        }

        private void doProcess(HttpServletRequest req, HttpServletResponse resp) {
        //write your code
        }
}



Back to top

------------------------- We hope you got necessary Info On -----------------------------------------

Servlet Post Get


Servlet Post Get

-------------------------------------------------------------------------------------------------------



Face Book
Request for a Mock Interview/Training

Get a PDF

Face Book
Same look (Read) on any device, this is Ads free