Thanks,
indeed the <jsp:include> actions you have before the <jsp:forward>
action causes the content of the page to be sent to the browser
but flush="true" doesn't solve the problem. To avoid "committing
to early" this solution worked out fine:

<%@ page import="InterviewBean" %>
<jsp:useBean id="iBean" scope="session" class="InterviewBean"/>
<jsp:setProperty name="iBean" property="*"/>
<% request.setAttribute("title","Interview"); %>
<%@ include file="Header.html" %>
<%@ i n c l u d e   f i l e ="InterviewForm.html" />
<%@ i n c l u d e   f i l e ="FormValidation.jsp" />
<% if (request.getAttribute("ok")=="true") { %>
<jsp: forward page="InterviewResponse.jsp" />
<% } %>

Stefan Ullrich


-----Ursprungliche Nachricht-----
Von: A mailing list about Java Server Pages specification and reference
[mailto:[EMAIL PROTECTED]]Im Auftrag von Hans Bergsten
Gesendet: Sonntag, 10. September 2000 03:15
An: [EMAIL PROTECTED]
Betreff: Re: include=Yes,forward=not?!


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

===========================================================================
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