tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Tim Moore" <tmo...@blackboard.com>
Subject RE: JSP Question
Date Wed, 08 Jan 2003 19:19:01 GMT
> -----Original Message-----
> From: Luc Foisy [mailto:Luc.Foisy@technical-magic.com] 
> Sent: Wednesday, January 08, 2003 1:54 PM
> To: Tomcat User List (E-mail)
> Subject: JSP Question
> 
> 
> 
> I am trying to use <%@ include file="filename" %>
> 
> I am sending to the page that has this with the line: 
> response.sendRedirect("main.jsp?p="+applicationJar.getPageName());
> 
> So in main.jsp I would like to include an external file to 
> insert into a default page, something like:
> 
> <SOME DEFAULT PAGE STUFF HERE>
> <%@ include file="filename" %>
> <SOME DEFAULT PAGE STUFF HERE>
> 
> but I would like to replace "filename" with request.getParameter("p")
> 
> Any one have any idea how to do this?

The <%@ include %> syntax is a static inclusion that happens at
translation time, so it can't depend on runtime parameters.

You want to use:
<jsp:include page='<%= request.getParameter("p") %>'/>
(see the JSP spec for details)

Be forewarned that you won't be able to access the enclosing page's
local variables from within the included page (as you can with static
includes), but if you add those variables to the request context you'll
be able to access them that way.

-- 
Tim Moore / Blackboard Inc. / Software Engineer
1899 L Street, NW / 5th Floor / Washington, DC 20036
Phone 202-463-4860 ext. 258 / Fax 202-463-4863


--
To unsubscribe, e-mail:   <mailto:tomcat-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:tomcat-user-help@jakarta.apache.org>


Mime
View raw message