Thanks, Mark. Your explanation was good but the code didn't do it. On Mon, Feb 10, 2020 at 12:10 PM Mark Thomas <ma...@apache.org> wrote:
> On 10/02/2020 18:03, Richard Monson-Haefel wrote: > > Hi Simon, > > > > Thanks for the response but I don't think that is the issue. I can use > the > > <context-param> instead, but I want to use the initParam for the JSP page > > which is named and mapped in the <servlet> element. Perhaps I'm still > > missing something. > > The EL implicit object initParam holds the *ServletConext*'s init > params, not the Servlet's. > > You probably want something like (untested) > > ${ pageContext.servletConfig.initParameter("greeting_color") } > > Mark > > > > > > On Mon, Feb 10, 2020 at 12:00 PM Simon Funnell <simonfunn...@gmail.com> > > wrote: > > > >> 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 > >> > > > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org > For additional commands, e-mail: users-h...@tomcat.apache.org > > -- Richard Monson-Haefel https://twitter.com/rmonson https://www.linkedin.com/in/monsonhaefel/