JPG
JPG

Reputation: 1255

unable to get init-parameter from servlet context using EL

I am trying to get value of init parameter defined in web.xml file. But I am getting Http Status 500 exception.

code to get init parameter in JSP file:

init param: ${pageContext.servletContext.initParameter.mob}

web.xml:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
  <welcome-file-list>
    <welcome-file>one/index.html</welcome-file>
  </welcome-file-list>
<context-param>
<param-name>mob</param-name>
<param-value>nokia</param-value>
</context-param>
</web-app>

there is no problem when i try to get init parameter without EL using jsp syntax. But with EL its causing error. can anyone tell me how can i get this using EL

Upvotes: 2

Views: 1575

Answers (1)

Koitoer
Koitoer

Reputation: 19543

Try using this expression.

${initParam['mob']} 

Or maybe

${pageContext.servletContext.initParameter['mob']}

Upvotes: 3

Related Questions