Hi,

<%@ include%> can't be used the way you are trying to. It's a static
include, only done when the JSP is compiled, because of this your runtime
assignment of "applPath" has never taken place.

<jsp:include> is done at runtime but I don't think the tag can handle your
dynamic page/path assignment.

To do a dynamic include in JSP you'll have to use the RequestDispatcher:

<%
  RequestDispatcher rd = request.getRequestDispatcher(appPath +"/body.inc");
  rd.include(request, response);
%>

Brgds
Mathias

-----Ursprungligt meddelande-----
Från: A mailing list for discussion about Sun Microsystem's Java Servlet
API Technology. [mailto:[EMAIL PROTECTED]]För Galbreath,
Mark
Skickat: den 4 oktober 2002 13:13
Till: [EMAIL PROTECTED]
Ämne: Re: problem with <@include file %>


Try <%= instead of <% for the assignment.  (And I hope you already tried
this instead of wasting our time....)

-----Original Message-----
From: raju punith [mailto:[EMAIL PROTECTED]]
Sent: Friday, October 04, 2002 12:23 AM
To: [EMAIL PROTECTED]
Subject: problem with <@include file %>


Hi everyone,

following is my jsp snippet .


<html>
  <head>
     <title>Home Page</title>
  </head>
  <body>
     <% String applPath =
application.getInitParameter("WEBAPP");%>
     <%@ include file = "<%=appPath%>/body.inc"%>
     <%@ include file = "<%=appPath%>/banner.inc"%>

     <% String userName = (String)
session.getAttribute("userName"); %>

        <% if (null == userName) {%>
           <%@ include file =
"<%=appPath%>/navbar_no_logout.inc"%>
             <%} else {%>
               <%@ include file =
"<%=appPath%>/navbar_with_logout.inc"%>
            <%}%>

      <#### rest of the code  ########>

        </body>

</html>


the problem: when i invoke the jsp i get the following
error

org.apache.jasper.compiler.CompileException:
/index.jsp(23,9) File "<%=appPath%>/body.inc" not
found
        at
org.apache.jasper.compiler.JspParseEventListener.handleDirective(JspParseEve
ntListener.java:789)


any help would be much appreciated.


Thanks



__________________________________________________
Do you Yahoo!?
New DSL Internet Access from SBC & Yahoo!
http://sbc.yahoo.com

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to