This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
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


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "How to use getServletConfig()" Watch "How to use getServletConfig()" New topic
Author

How to use getServletConfig()

ram gaurav
Ranch Hand

Joined: Mar 29, 2006
Posts: 208
HI

In web.xml i have written ,

<servlet>
<servlet-name>servlettest</servlet-name>
<servlet-class>ServletTest</servlet-class>

<init-param>
<param-name>ram</param-name>
<param-value>JAI SHRI RAM</param-value>
</init-param>
</servlet>

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>

Thanks
Regards
Gaurav
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="http://sd.balasubramani.googlepages.com" target="_blank" rel="nofollow">www.sd.balasubramani.googlepages.com</a>
Ben Souther
Sheriff

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: http://aspose.com/file-tools
 
subject: How to use getServletConfig()