Discussions

Web tier: servlets, JSP, Web frameworks: multiple <%@ include file="file.jsp" %> tags

  1. multiple <%@ include file="file.jsp" %> tags (6 messages)

    Hi all,

    Apache Tomcat's JSP compiler won't let me include a jsp file more than once in a page:

    org.apache.jasper.compiler.ParseException: Seen file /WEB-INF/include/loginform.jsp already, maybe this is a recursive include?!

    I just have 2 spots in my page where I want to include that file. It's not even recursive since I don't let the jsp include itself. This is at most iterative inclusion.

    Is this normal behaviour? (I guess so, Sun declared Tomcat to be the reference implementation)
    I can't find anything on this in jsp1_1-spec.pdf.

    Can I get around this?

    Erik
  2. Tomcat support multiple include.[ Go to top ]

    I think that the pages you want to include have duplicate
    variables.
  3. Tomcat support multiple include.[ Go to top ]

    Why would that be a problem?
    I don't see the problem in this construction:

    <HTML>
    <% if( some_condition ) {
    %><%@ include file="content.jsp" %><%
    } else {
    %><%@ include file="content.jsp" %><%
    }
    %>
    </HTML>

    I just want to include content.jsp in both scopes. I see no harm.

    Erik
  4. Tomcat support multiple include.[ Go to top ]

    Laun,

    This is a better example:

    $ cat myjsp.jsp
    <HTML>
    <%@ include file="some_line.jsp" %>
    <%@ include file="some_line.jsp" %>
    </HTML>
    $ cat some_line.jsp
    <B>only static HTML in here</B>

    Still I get:

    org.apache.jasper.compiler.ParseException: Seen file /some_line.jsp already, maybe this is a recursive include?!

    There aren't even scriplets in the included file.

    Erik
  5. hi, the following examle include.jsp works on tomcat.
    Maybe it is helpful for u.

    michae
    ------------------------------------------------

    <html>
    <!--
      Copyright (c) 1999 The Apache Software Foundation. All rights
      reserved.
    -->

    <body bgcolor="white">

    <font color="red">

    <%@ page buffer="5" autoFlush="false" %>

    <p>In place evaluation of another JSP which gives you the current time:

    <%@ include file="foo.jsp" %>

    <p> <jsp:include page="/jsp/include/foo.html" flush="true"/> by including the output of another JSP:

    <jsp:include page="foo.jsp" flush="true"/>

    :-)

    </html>
  6. Indeed.. that does work.

    What is the difference between

    <%@ include file="file.jsp" %>
    and
    <jsp:include page="file.jsp" flush="true" />

    ?

    Erik
  7. <%@include is compile time Include.. Whereas jsp:include is run time include statement.
    I tried the multiple include statements in ServletExec. It is working fine..

    -Shibu