File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes Problems with RequestDispatcher Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Problems with RequestDispatcher" Watch "Problems with RequestDispatcher" New topic

Problems with RequestDispatcher

Michael Chua

Joined: Apr 21, 2004
Posts: 11
I am recently using the RequestDispatcher to relocate the request to another servlet
When I call the RequestDispatcher's forward method in the doPost method of servlet a to servlet b, It always ends up in servlet b's doPost method
What I want to do is forward the request to servlet b's doGet method
So what should I do achieve this requirement?

Just take my heart when you go<br />I don't have a need for it anymore<br /> <br />5/9 SCJP 1.4 passed<br />8/15 SCBCD 1.3 passed<br />SCWCD (in progress)
Jeroen Wenting
Ranch Hand

Joined: Oct 12, 2000
Posts: 5093
you can't.
When you forward a request the request method is forwarded as well. After all the entire request is sent to the other resource like it came directly from the client (with the stuff added you did in the forwarding servlet of course).

A POST request will always be a POST request, learn to live with it.

Michael Chua

Joined: Apr 21, 2004
Posts: 11
thanks very much for the fast reply
I think I'll just think of some other way
I agree. Here's the link:
subject: Problems with RequestDispatcher
It's not a secret anymore!