Try checking your results vector first, immediately redirecting to the error
page, before continuing on with <html><head>etc....
Within the main body of your page, you write out the <html><head>etc... and
then begin to cycle through the results vector. If there is any error
occuring there, it is probably too late to redirect to an error page. The
previous HTML has probably been flushed.
I agree with Geert, there is perhaps something not quite right with Tomcat
in this regard. I'm not sure what the point of having the <%@ page
errorPage="" %> capability, if the response cannot be buffered
appropriately. I've had a similar problem with buffered responses, and
Tomcat does not seem to be able to "hold it's buffer", no matter what you
set it to. Or maybe I've been doing it wrong. (Or maybe it converts
whitespace and hard returns between tags into output!)
-----Original Message-----
From: davo jones [mailto:optimation@h...]
Sent: Thursday, March 15, 2001 2:29 PM
To: Pro_JavaServer_Pages
Subject: [pro_jsp] RE: Response has already been commited error
Hi,
Thanks for the detailed response, it is much appreciated.
Yes, i do get the: java.lang.IllegalStateException: Response has already
been committed error.
I am still a little confused as to how to remedy this problem. I have
enclosed my jsp code below if that is of any help.
<%@ page errorPage="errorpage.jsp" %>
<jsp:useBean id="site" scope="session" class="SiteAnalyser" />
<%
site.setSearchString(request.getParameter("search"));
String searchlevel = request.getParameter("level");
if(searchlevel.equals("1"))
site.setSearchLevel(1);
else if(searchlevel.equals("2"))
site.setSearchLevel(2);
site.siteConnector();
Vector results[] = site.getSearchData();
%>
<html>
<head>
<title>jobIT.com - Search results for '<%= request.getParameter("search") %
>'</title>
</head>
<body bgcolor="#808080" text="#FFFFFF" vlink="#3399FF" alink="#0099FF"
link="#3399FF">
<tr>
<td width="100%" background="images/back.jpg" height="94"
valign="top" align="left">
<p align="center"><font face="Arial" size="2">Results from search
for: <b>'<%= request.getParameter("search") %>'</b>
<p>
<center>To have these results e-mailed to you,<br>
enter your e-mail address:
<form method="POST" action="mailer.jsp">
<input type="text" name="email" size="20">
<%
int counter = 0;
for(int count1 = 0; count1 < 4; count1++)
{
for(int t = 0; t < results[count1].size(); t++)
{
Job job = (Job)results[count1].elementAt(t);
%>
<input type="hidden" value="<%= job.title() %>"
name="<%= counter %>">
<%
counter++;
}
}
%>
<input type="hidden" value="<%=counter%>" name="number">
<input type="submit" value="Go!" name="B1"></p>
</form>
</center>
<p>
<%
for(int count = 0; count < 4; count++)
{
for(int i = 0; i < results[count].size(); i++)
{
Job job = (Job)results[count].elementAt(i);
out.println(job.title());
%>
<P>
<%
out.println(job.link() );
}
}
%>
</font></td>
</tr>
</table>
</center>
</div>
</body>
</html>
If you could help me further, i would be greatful as this is for my final
year degree project which has to be in next week.
Thanks
> I'm not sure, but I think the problem is this:
> a part of the page is already flushed to the user, but then you want to
> redirect to some other servlet or JSP. This shows an error. I'm not sure
> whether it will help but you could try to increase the page buffer size.
>
> also, another note on that error:
>
> Are you using Tomcat?
> One particularly unintuitive message produced by Tomcat is
> java.lang.IllegalStateException: Response has already been committed. At
> face value, this means that an attempt has been made to forward the
request
> after at least a partial response has been sent to the client; this is
> illegal, hence this error. What is less intuitive is that with some
versions
> this error occurs when an exception within the page causes an error page
to
> be accessed; if the response to the client has already been 'committed'
(in
> other words, the output buffer has been flushed) when the exception
occurs,
> the attempt to forward control to the error page will fail in this
manner.
>
>
> regards
>
> Geert
>
> > -----Original Message-----
> > From: davo jones [mailto:optimation@h...]
> > Sent: donderdag 15 maart 2001 11:28
> > To: Pro_JavaServer_Pages
> > Subject: [pro_jsp] Response has already been commited error
> >
> >
> > Hi,
> >
> > I have a web app in jsp/java at the following address:
> > headrunner.kgbinternet.com/dheapy/index.html
> > The problem is that i keep getting a response has already been commited
> > error when i try to perform a search. Can any one help with why this is
> > happening?
> >
> > Thanks