Tuesday, June 28, 2011

How to config a JSP file in web.xml?

Declare following in web.xml file.
<servlet>
<servlet-name>jspName</servlet-name>
<jsp-file>/jspPage.jsp</jsp-file>
     <init-param>
          <param-name>hello</param-name>
           <param-value>test</param-value>
     </init-param>
</servlet>
 
<servlet-mapping>
     <servlet-name>jspName</servlet-name>
     <url-pattern>/jspPage</url-pattern>
 </servlet-mapping>
You can get the value against the parameter hello using following in your jsp page.
<%= config.getInitParameter("hello");%>

--
If you could click on some of the google ads you see on the right side. It will help me to run this blog and motivates me ;)