try this:

<jsp:include page="/test.jsp">
  <jsp:param name="buttontext" value="<%=theText%>" />
</jsp:include >

:crook

-----Original Message-----
From: Chris Tucker [mailto:[EMAIL PROTECTED]]
Sent: Friday, November 09, 2001 2:14 PM
To: [EMAIL PROTECTED]
Subject: Passing parameters to includes


Hi all,

I was wondering how other people approach the problem of passing parameters
to include files (or even if this is really something that it's a good idea
to do...).  For example, say I want to specify some button text for an
included file, I may want pass a parameter called "buttontext" with the
value "Hello".  The way I've been approaching this so far is to encode the
parameters as a query string on the include URL, e.g.
<jsp:include page="test.jsp?buttontext=Hello" />
but this doesn't really scale up to anything more than simple textual
arguments.  I could add stuff to the session or context, allowing me to use
more complex objects, but I don't want to be creating a load of
interdependencies as far as attribute naming etc. is concerned between an
include file and the file including it.  Ideally, I'd like to just be able
to parameterise the include as one would a method.

Any suggestions?

Chris Tucker

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST
DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://archives.java.sun.com/jsp-interest.html
 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.jsp
 http://www.jguru.com/faq/index.jsp
 http://www.jspinsider.com

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://archives.java.sun.com/jsp-interest.html
 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.jsp
 http://www.jguru.com/faq/index.jsp
 http://www.jspinsider.com

Reply via email to