tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael Wentzel <>
Subject RE: Invoking a servlet from JSP
Date Tue, 23 Jan 2001 12:37:50 GMT
> I have a self-contained servlet that returns a single value.  
> I am trying to
> include the output of this servlet in-line on an HTML/JSP 
> page.  When I try
> to invoke the servlet using the following JSP INCLUDE tag, 
> the page bombs
> with Exception #500 (java.lang.IllegalStateException: Writer 
> is already
> being used for this request):
> <jsp:include page="/servlet/TestServlet" flush="true">
>    <jsp:param name="type" value="apples" />
> </jsp:include>
> But when I use the JSP FORWARD tag, the servlet and page work 
> perfectly,
> except for the fact that the page returned contains only the 
> output of the
> servlet (as expected):
> <jsp:forward page="/servlet/TestServlet" >
>    <jsp:param name="type" value="apples" />
> </jsp:forward>
> How can I accomplish what I need?  BTW, I am using Tomcat 3.2.1.

One solution I can think of is using the second option
have the servlet forward back to the referrer jsp passing
the answer value(s).

The reason the include doesn't work is because in your servlet there
is a call to getWriter() while the jsp page still has a handle on
the JSPWriter.

Another option might be replacing your servlet with a bean but I'm not
sure about that.

Michael Wentzel
Software Developer
Software As We Think

View raw message