How can we send a POST request when we call getRequestDispatcher() functions ? It is easy to make a GET request but I don't know how for POST one.

Alex Chaffee

Unfortunately, the servlet spec does not allow you to change the HTTP method of a dispatched request (from GET to POST or vice versa).

This is a problem if you want to call a servlet that only responds to a POST request, or that has different implementations for doGet and doPost. (This is poor servlet design, but using someone else's servlet, you may not have a choice.)

You can work around this by using a URLConnection as in http://www.jguru.com/jguru/faq/view.jsp?EID=62798

See also http://www.jguru.com/jguru/faq/view.jsp?EID=740
0 Comments  (click to add your comment)
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

About | Sitemap | Contact