• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

getting initialisation parameters in JSP

 
archana vishwanath
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi!
<init-param>
<param-name>
uploadDir
</param-name>
<param-value>
D:\tomcat\webapps\b2b2\images
</param-value>

String dirName = config.getInitParameter("uploadDir");

This way I can get my initialization parameters from a web.xml file in
servlet.

But this is not working for JSP.Why?OR How can I get values
from web.xml file in JSP?
 
Ali Gohar
Ranch Hand
Posts: 572
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can get the init parameters using jsp through following code:
Declare the following tags in web.xml against your jsp
<servlet>
<servlet-name>myjsp</servlet-name>
<jsp-file>/myjsp.jsp</jsp-file>
<init-param>
<param-name>hello</param-name>
<param-value>test</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>myjsp</servlet-name>
<url-pattern>/myjsp</url-pattern>
</servlet-mapping>
this is how you can get the init paramters.
 
archana vishwanath
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Ali Gohar!It works fine
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic