tomcat-taglibs-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "James Strachan" <>
Subject Re: Parameters in include tag
Date Thu, 29 Mar 2001 17:09:59 GMT
Hi Manuel

This one has bitten me more times than I like to remember. The quick answer is move to JSP
1.2 and it solves this problem - Tomcat 4.x supports JSP 1.2. 

The more detailed answer is that in JSP 1.1 there is a problem using BodyTags which contain
a <jsp:include> inside their body. In JSP 1.1 the output of <jsp:include> is meant
to go straight to the HttpServletResponse so the BodyTag never sees the output - so even if
your code would run without throwing an exception, the XML you are trying to style would go
to the users browser and the <xsl:apply> tag wouldn't get any XML to style.

I hit this limitation all the time, here are my 2 workarounds - both are far less than ideal
and will be removed as soon as I can develop on JSP 1.2...

1) use static includes

<xsl:apply xsl="xsl/restaurantstable.xsl">
    <%@ include file="/something.jsp" %>

In this model you can use scripting variables to communicate between the 2 bits of JSP

2) use a seperate HTTP request to call your 'include'.

if you had a tag library to perform a http request you could do something like this:-

<xsl:apply xsl="xsl/restaurantstable.xsl">
    <io:http url="/servlet/Restaurants">
        <io:param name="State" value="<%= stateCode %>"/>

If you're stuck and need a tag library to do http requests as shown above, I posted an "io
tag library" to the taglibs-dev list recently, though it hasn't been officially accepted yet,
so use at your own risk. Mail me privately if you like and I can send you the the tag lib.


----- Original Message ----- 
  From: Manuel Alzola 
  Sent: Thursday, March 29, 2001 9:41 PM
  Subject: Re: Parameters in include tag

  Thanks Pierre.

  <jsp:include page="/servlet/Restaurants" flush="true">
      <jsp:param name="State" value="<%= stateCode %>"/>

  works fine, but when I try to nest it in the following way

  <xsl:apply xsl="xsl/restaurantstable.xsl">
      <jsp:include page="/servlet/Restaurants" flush="false">
          <jsp:param name="State" value="<%= stateCode %>"/>

  I get the error 
  javax.servlet.ServletException: Illegal to flush within a custom tag
  and if I turn off flush I receive 
  jsp:include page="..." flush="true" es la unica combinacion valida en JSP 1.0
  the xsl tag I´m using is the one from jakarta and my server is Tomcat 3.2

  ----- Original Message ----- 
  From: "Pierre Delisle" <>
  To: <>
  Sent: Thursday, March 29, 2001 3:51 AM
  Subject: Re: Parameters in include tag

  > > Manuel Alzola wrote:
  > > 
  > > Hello. I´m using the include tag to put the output of a servlet into a jsp
  > > page. It works fine but I also need to put some parameters in the request. Is
  > > there a nested tag to let me do this? Is there any other way to accomplish it?
  > You may use:
  > <jsp:include page="urlSpec" flush="true">
  >   { <jsp:param .... /> }*
  > </jsp:include>
  >     -- Pierre

View raw message