Stefan Ullrich wrote:
>
> Hi everyone,
> can anybody tell me why I can't forward from my "Interview.jsp" shown below
> to the "InterviewResponse.jsp" (throws a java.lang.IllegalStateException:
> Response has already been committed)? Exchanging forward with include causes
> no problems at all!
> Thanx for a hint
> regards
> Stefan Ullrich
>
> <%@ page import="InterviewBean" %>
> <jsp:useBean id="iBean" scope="session" class="InterviewBean"/>
> <jsp:setProperty name="iBean" property="*"/>
> <% request.setAttribute("title","Interview"); %>
> <%@ include file="Header.html" %>
> <jsp:include page="InterviewForm.html" />
> <jsp:include page="FormValidation.jsp" />
> <% if (request.getAttribute("ok")=="true") { %>
> <jsp: f o r w a r d page="InterviewResponse.jsp" />
> <% } %>

Because the <jsp:include> actions you have before the <jsp:forward>
action causes the content of the page to be sent to the browser (the
response is "committed"). In fact, the syntax you use in your example
is invalid; you must use the "flush" attribute with the value "true"
for <jsp:include> in JSP 1.0/1.1.

Look at it this way. You can use includes to let different resources
(JSP pages or servlets) cooperate on generating the response, but forward
means you give the control of the request (and the response) to another
resource altogether. The target resource only have full control if nothing
has already been sent to the browser, hence the restriction.

Hans
--
Hans Bergsten           [EMAIL PROTECTED]
Gefion Software         http://www.gefionsoftware.com

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets

Reply via email to