On Mon, 19 Mar 2001, Scott Walter wrote:

> Is this even possible:
> 
> I have a JSP page called (page1.jsp), that uses
> jsp:include to include page2.jsp.  Page2.jsp has a
> custom tag on it.  Inside my custom tag based on a
> condition I want to send the user to another page,
> let's say page3.jsp.
> 
> The way I attempted to do this is within my custom tag
> is to call a sendRedirect().  However I keep on
> getting a response has already been committed
> exception, I have also tried setting a session
> attribute and within page1.jsp to check the session
> attribute and if it has a certain value, try to do a
> sendredirect in page1.jsp, this gives me the same
> exception.
> 
> Is this feat possible?
> 

Not possible the way you are trying it.

The reason is that a resource included by <jsp:include> (or
RequestDispatcher.include()) is prohibited from modifying request headers,
which is required in order to do a response.sendRedirect() call.

You might try using the include directive (<%@ include
file="page2.jsp" %>) instead.  This causes the include to happen at
compile time, so that the entire result is in a single page -- and
therefore the sendRedirect() will work.

> 
> 
> 
> =====
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> Scott
> 

Craig McClanahan


Reply via email to