aspose file tools*
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 EJB 3 in Action this week in the EJB and other Java EE Technologies 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()
 
Similar Threads
how to get init-param in jsp
web.xml configuration Problem
Access Servlet InitParameters in JSP
problem in getInitParameterNames() method of ServletConfig
Why this code to get Init Param in JSP not work?