Thanks!

I tried Method #1...using the declaration <%! String headingText = "Login";
%> with the JSP page...and it works..BUT ONLY if the include directive: <%@
include file="relativeurl" %> is used.

I discovered Method #1 will not work with the JSP include tag : <jsp:include
page="relativeurl" flush="true" />.  Why...well the spec says...a
declaration <%! String headingText = "Login"; %> has a translation unit
scope, so it is valid in the JSP page and any of its static include
files...EXCEPTION...the scope of a declaration does not include DYNAMIC
FILES included with the <jsp:include> tag.

I appreciate the help!
Steve.



-----Original Message-----
From: Mandar Raje [mailto:[EMAIL PROTECTED]]
Sent: Monday, November 15, 1999 5:26 PM
To: Blazevich, Steve; [EMAIL PROTECTED]
Subject: Re: Setting a variable in a JSP page and accessing it from an
INCLUDEfile


Hi,

  There are a couple of ways:

1) you can declare the variable using declaraton (instance scope)
  <%! String headingText = "Login"; %>

2) you can create the variable in the "request" object and
then access it from the included jsp.

  request.setAttribute("headingText", headingText");

And in the included jsp:

 String headingText = (String) request.getAttribute("headingText");

Thanks,
Mandar.

"Blazevich, Steve" wrote:

> Hello all,
>
> Is it possible (if so...how) to set a variable in a JSP page (i.e.. String
> headingText = "Login") and then access that variable in an include file
(<%=
> headingText %>)?
>
> Thanks for the help,
> Blaze.
>
> Steve Blazevich
> Phone:  303-967-0402
> Fax:  303-770-5452
>
>
===========================================================================
> To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
JSP-INTEREST".
> FAQs on JSP can be found at:
>  http://java.sun.com/products/jsp/faq.html
>  http://www.esperanto.org.nz/jsp/jspfaq.html

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
FAQs on JSP can be found at:
 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html

Reply via email to