TGM
TGM

Reputation: 1679

Dispatcher forward method from POST to GET

I need to forward from my FooServlet doPost method to BarServlet doGet method. Is there a way to solve this?

Currently I'm calling the doGet method from my doPost but I'm sure that this isn't the best practice.

Upvotes: 1

Views: 4492

Answers (1)

Gustav Barkefors
Gustav Barkefors

Reputation: 5086

Assuming HTTP servlets intended for web-based use, I would recommend a ServletResponse.sendRedirect(...) to have the client request service from BarServlet in order to convey some insight into the server's view on things, and to avoid unintended re-POSTs, and so on.

Upvotes: 4

Related Questions