On Sat, 7 Sep 2002, Dror Matalon wrote:
> How do you do the opposite, how do you fetch a var from a tag into your
> java code? I'd like to have a tag that fetches the user name and makes
> it available to the java code. Something like:
>
> <%
> String user = "";
> %>
>
> <zp:authenticate "<%=user%>"=userName/>
>
> <%
> if(userName.equals("joe"))
> ...
> else
> ...
> %>
In JSP 1.2, this is done using either the <variable> element in the TLD or
a TagExtraInfo class. See the spec or a book for details.
In newer pages -- those that use JSTL or the upcoming JSP 2.0 standard --
it will probably be easier to use the expression language, which simply
requires that you insert variables into page, request, session, or
application scope. The use of scripting variables, which are tied
primarily to scriptlet code, effectively becomes obsolete, or at least
unfashionable. (Of course, JSP will always support scripting variables,
but the goal is for people to wonder, "Why would I ever do it *that* way
now?")
--
Shawn Bayern
"JSTL in Action" http://www.jstlbook.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