• Post Reply Bookmark Topic Watch Topic
  • New Topic

reading init params in JSP  RSS feed

 
Man Pan
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a jsp page which needs to read some initial values (only once - at servlet startup) and change its behavior accordingly.

The problem is I am not able to read the init param successfully.

Here is what I have:

* My application context is "TEST"
* It is runing on Tomacat 5.0

router.jsp (under the /webapps/TEST/COMMON/ directory)
============================================================
<%! String myValue;
public void jspInit()
{
myValue = getServletConfig().getInitParameter("param1");
}
%>

Value of variable myValue is : <%=myValue%>

web.xml (under the /webapps/TEST/WEB-INF/ directory)
============================================================
<web-app>
....
<servlet>
<servlet-name>Router</servlet-name>
<jsp-file>/COMMON/router.jsp</jsp-file>
<init-param>
<param-name>param1</param-name>
<param-value>123</param-value>
</init-param>
<load-on-startup>-1</load-on-startup>
</servlet>
...
</web-app>


Any pointers about what's wrong will be appreciated.
[ November 17, 2004: Message edited by: Bear Bibeault ]
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!