Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to use getServletConfig()

 
ram gaurav
Ranch Hand
Posts: 208
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 116
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic