File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSP and the fly likes Mutiple forward() calls Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Make it so: Java DB Connections & Transactions this week in the JDBC forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Mutiple forward() calls" Watch "Mutiple forward() calls" New topic

Mutiple forward() calls

sajith pc

Joined: Oct 05, 2009
Posts: 2

Hi all,

I have jsp page which uses the RequestDispatcher.forward() method multiple times.

I am using the apache tomcat 6.x version as my server. I have three deployments in the named test1,test2,test3.

For a particular http request i need to pass to all the three deployments.

For that i wrote a jsp page put it under the webapps/ROOT/testfporward.jsp

While executing this i am getting the following error.
"cannot forward after response has been committed"

Is there is anything wrong in my code.
Which is correct way to invoking multiple http requests for a incoming request?
Please help me to solve this issue..
David Newton

Joined: Sep 29, 2008
Posts: 12617

What, precisely, are you trying to do? Include three other pages?
sajith pc

Joined: Oct 05, 2009
Posts: 2
Thank you for the quick reply.
No, i am not trying to including files.

I want to pass the HttpServletRequest to other three deployments in the server.

testforwrad.jsp get external http request, then i want to pass this request to all the three deployments test1,test2,tset3

Is this possible..
please help me
David Newton

Joined: Sep 29, 2008
Posts: 12617

Well, you can't forward a request once any output has been written to the client.

I suppose you could create a bunch of requests using a client library like Apache's HttpClient, but the purpose of what you're doing eludes me.
pankaj vijay
Ranch Hand

Joined: Apr 01, 2008
Posts: 75
It is not possible to forward a request if one is all ready commited.. yes you can do 1 thing put if & else in such a way that at a time only one request can be forwarded...

Pankaj Vijay (SCJP, SCBCD)
Learn Core Java,Learn Servlet Jsp, SCJP Questions,Struts Tutorial
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63551

"sajith pc", please check your private messages for an important administrative matter.

[Asking smart questions] [About Bear] [Books by Bear]
I agree. Here's the link:
subject: Mutiple forward() calls
It's not a secret anymore!