aspose file tools*
The moose likes JSP and the fly likes getting initialisation parameters in JSP Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "getting initialisation parameters in JSP" Watch "getting initialisation parameters in JSP" New topic
Author

getting initialisation parameters in JSP

archana vishwanath
Ranch Hand

Joined: Mar 09, 2004
Posts: 39
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

Joined: Mar 18, 2004
Posts: 572
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

Joined: Mar 09, 2004
Posts: 39
Thanks Ali Gohar!It works fine
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: getting initialisation parameters in JSP
 
Similar Threads
How can we read initparameter(String t) of a servlet
Why this code to get Init Param in JSP not work?
implicit object doubt
Servlet initParameter in EL
web.xml and file uploading