Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

reading init params in JSP

 
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 ]
 
No matter how many women are assigned to the project, a pregnancy takes nine months. Much longer than this tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!