wood burning stoves 2.0*
The moose likes Servlets and the fly likes A servlet in a jsp include Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "A servlet in a jsp include" Watch "A servlet in a jsp include" New topic
Author

A servlet in a jsp include

Anthony Smith
Ranch Hand

Joined: Sep 10, 2001
Posts: 285
Lets say I have a jsp file like the following:
<table cellspacing="0" width="100%" cellpadding="0" border="0">
<tr>
<td valign="top" width="80%">
<jsp:include page="<%= next_page %>" flush="true" />
</td>
</tr>
<tr>
<td valign="top" >
<jsp:include page="<%= another_page %>" flush="true" />
</td>
</tr>
</table>
************************************
This works fine if both of the pages are jsp pages. However in my situation the last include will be jsp not actually in a public web folder. Instead it will be on the same computer but I have a servlet that will display the page. The servlet works fine alone, but tryng to use it in the include gives me:
Exception: java.lang.IllegalStateException: setting buffer after writing to the writer.............
And so on and so forth. Is there any hope for this?
Terence Doyle
Ranch Hand

Joined: May 30, 2001
Posts: 328
HI,
When you use the <jsp:include> tag, the buffer is flushed before invoking the the included page - servlet in this case.
After this happens headers can't be set nor will <jsp:forward> work.
Is this the cause of your problem??
Try changing to the include directive instead to test.
<%@include file="filename" %>

Hope that helps,

------------------
Terry Doyle
Sun Certified Programmer for Java 2 Platform


Raising Flares debut album 'Ignition' out now

http://www.raisingflares.com

Terry Doyle <br />SCPJ 1.4 , SCWCD , SCMAD(Beta)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: A servlet in a jsp include
 
Similar Threads
How to include a part of html code in to a jsp page?
jsp:include not working
Failed to display login link once user has logged out
jsp:include and c:import combination/nesting
jsp:include in JSF JSP