Hi,
Tomcat version: 9.0.30
Operating System: macOS 10.15.2
While I can access my initParam vis a JSP scriptlet I cannot access the
same initial paramter EL expression.
Here is the JSP code I'm using
<HTML>
<BODY>
<H1>
<font color="<%= config.getInitParameter("greeting_color")
%>">Hello</font><font color="black"> ${param.name} from hello.jsp</font>
</H1>
color is ${initParam["greeting_color"]}
</BODY>
</HTML>
Here is my web.xml declaring the initial parameters
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"
version="4.0"
metadata-complete="true">
<!-- JSP Mapping -->
<servlet>
<servlet-name>HiJsp</servlet-name>
<jsp-file>/hello.jsp</jsp-file>
<init-param>
<param-name>greeting_color</param-name>
<param-value>green</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>HiJsp</servlet-name>
<url-pattern>/hola/*</url-pattern>
</servlet-mapping>
</web-app>
Here is the output (source)
<HTML>
<BODY>
<H1>
<font color="green">Hello</font><font color="black"> richard from hello.jsp
</font>
</H1>
color is
</BODY>
</HTML>
I don't understand why the JSP expression <%= %> works but the EL
expression ${ } doesn't. I've tried many variations and other EL implicit
objects I've tried worked fine.
What am I missing?
The WAR is attached for your convenience.
--
Richard Monson-Haefel
https://twitter.com/rmonson
https://www.linkedin.com/in/monsonhaefel/
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]