In your web.xml you want:

<context-param>
    <param-name>greeting_color</param-name>
    <param-value>green</param-value>
  </context-param>

I think you have defined an initialization parameter for the servlet, not
the context.

On Mon, 10 Feb 2020 at 17:54, Richard Monson-Haefel <monsonhae...@gmail.com>
wrote:

> 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: users-unsubscr...@tomcat.apache.org
> For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to