It's not a secret anymore!
The moose likes JSP and the fly likes How to use getServletConfig() Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "How to use getServletConfig()" Watch "How to use getServletConfig()" New topic

How to use getServletConfig()

ram gaurav
Ranch Hand

Joined: Mar 29, 2006
Posts: 208

In web.xml i have written ,


<param-value>JAI SHRI RAM</param-value>

and when in my JSP i am writting ,

String value1 = getServletConfig().getInitParameter("ram");

then it showing the value of "value1" as null.

Please tell me that how to deal read value from there in <init-param>

Balasubramani Dharmalingam
Ranch Hand

Joined: Dec 06, 2004
Posts: 116
Init parameters that you have given inside the <servlet> entry of servletTest will be available only for that servlet. You cannot get it from other servlets or JSPs.

Balasubramani SD,<br />SCJP 1.4,SCWCD 1.4,SCJP 5.0<br /><a href="" target="_blank" rel="nofollow"></a>
Ben Souther

Joined: Dec 11, 2004
Posts: 13410

I have examples of both servlet config init params and Context Init Params.

If you want the parameter to be available to all servlets and JSPs, then you would want to use the latter.

Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
I agree. Here's the link:
subject: How to use getServletConfig()
It's not a secret anymore!