You are viewing a plain text version of this content. The canonical link for it is here.
Posted to taglibs-user@tomcat.apache.org by "Carole E. Mah" <ca...@mama.stg.brown.edu> on 2002/05/03 18:34:28 UTC
printing taglib variables from inside a scriptlet
How does one print taglib variables from inside a scriptlet?
Is it possible?
e.g. the following does not work -- it returns the error
"Undefined variable: test"
thanks!
-carole
<%@ page import="java.io.*,java.util.*" %>
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
<c:set var="test" value="foobar" />
<%
try {
PrintWriter outFile = new PrintWriter(new FileWriter("blort.txt"));
outFile.println(test);
outFile.close();
}
catch (IOException e) {
System.err.println(e);
System.exit(1);
}
%>
- - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Carole E. Mah carolem@stg.brown.edu
Senior Programmer/Analyst
Brown University Scholarly Technology Group
phn 401-863-2669
fax 401-863-9313
http://www.stg.brown.edu/
personal: http://www.stg.brown.edu/~carolem/
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: printing taglib variables from inside a scriptlet
Posted by Shawn Bayern <ba...@essentially.net>.
On Fri, 3 May 2002, Carole E. Mah wrote:
> How does one print taglib variables from inside a scriptlet?
> Is it possible?
>
> e.g. the following does not work -- it returns the error
> "Undefined variable: test"
You need to retrieve the scoped variable manually, for it isn't a
scripting variable. For instance:
pageContext.findAttribute("test")
Note that this syntax is indeed inconvenient, which is why the JSTL EL is
useful in the first place. :-)
--
Shawn Bayern
"JSP Standard Tag Library" http://www.jstlbook.com
(coming this summer from Manning Publications)
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>