Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Servlet [response already committed error]  RSS feed

 
cup hsus
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
An HttpServletResponse object was used for getting the servletoutputstream and the same object was used in forward of RequestDispatcher.

But it shows an error saying

'response object is already committed'

How to get a ServletOutputStream using the HttpServletResponse Object as well use the same to forward.

I want the reply asap.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can do either or.
Why would you want the output stream if you are forwarding?
 
cup hsus
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm using the response object of the servlet to get the OutputStream for downLoading and after this process, it has to refresh my jsp page. So i'm using the response object to forward to that Jsp page.

Is there any other way to do this process
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can only have one response per request.

One solution is to send the redirect or forward first.
Then put some javascript in the page to which you've forwarded that makes the call to get the download file.
 
Rahim Vindhani
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Ben Souther:
You can only have one response per request.

One solution is to send the redirect or forward first.
Then put some javascript in the page to which you've forwarded that makes the call to get the download file.


Or else, put a javascript redirection code after downloading.. that will redirect request to another page.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Rahim Vindhani:


Or else, put a javascript redirection code after downloading.. that will redirect request to another page.


How would you do that?
Where would you put the javascript?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!