Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Cannot forward after response has been committed

 
Tomas Nilson
Ranch Hand
Posts: 33
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello!
My web hotel upgraded from Tomcat 3.X to 4.1.18 yesterday and now my site doesn't work anymore.
I have a html page where users fill out their username and password. It's a form which posts to a jsp login page. That one looks (partially) like this:
if (myBean.login(username, password))
{
session.setAttribute("firstname", myBean.getFirstname());
session.setAttribute("lastname", myBean.getLastname());
session.setAttribute("userid", myBean.getUserId());
response.sendRedirect("index2.jsp");

This worked fine before but now I get:
org.apache.jasper.JasperException: Cannot forward after response has been committed
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:248)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
...... and so on
Does anyone know what is happening??
I really appreciate a quick answer..!!
Thanks in advance, Tom
 
Michael ness
Greenhorn
Posts: 7
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Thomas,
This usually occurs because you have tried to output something to the browser before calling
response.sendRedirect. There is a buffer that as you send output fills up once it is full it is flushed and you can no longer redirect to another page. One solution is to increase the size of the buffer by using the following
<%@ page buffer="48k" autoFlush="true" %>
I think the default is 15k. However the better solution is just to make sure your not outputting anything before calling response.sendRedirect.
Michael
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic