This week's book giveaway is in the OCAJP forum.
We're giving away four copies of OCA Java SE 8 Programmer I Study Guide 1Z0-808 and have Jeanne Boyarsky & Scott Selikoff on-line!
See this thread for details.
The moose likes JSP and the fly likes mapping all jsps to single servlets init parameters Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA Java SE 8 Programmer I Study Guide 1Z0-808 this week in the OCAJP forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "mapping all jsps to single servlets init parameters" Watch "mapping all jsps to single servlets init parameters" New topic
Author

mapping all jsps to single servlets init parameters

Abhishek Reddy
Ranch Hand

Joined: Mar 28, 2006
Posts: 259
hi every i want to access init parameter values in jsp....is there any way to map all jsps to single servlets init-param values..
when i try to do this iam getting error..

<init-param>
<param-name>url</param-name>
<param-value>jdbcracle:thin:@localhost:1521rcl</param-value>
</init-param>
<init-param>
<param-name>name</param-name>
<param-value>scott</param-value>
</init-param>
<init-param>
<param-name>pass</param-name>
<param-value>tiger</param-value>
</init-param>
<servlet-name>smartcardJSP</servlet-name>
<jsp-file>/*.jsp</jsp-file>
</servlet>

<servlet-mapping>
<servlet-name>smartcardJSP</servlet-name>
<url-pattern>*.jsp</url-pattern>
</servlet-mapping>
------------------
when i do this way it is working for single jsp
<init-param>
<param-name>url</param-name>
<param-value>jdbcracle:thin:@localhost:1521rcl</param-value>
</init-param>
<init-param>
<param-name>name</param-name>
<param-value>scott</param-value>
</init-param>
<init-param>
<param-name>pass</param-name>
<param-value>tiger</param-value>
</init-param>
<servlet-name>smartcardJSP</servlet-name>
<jsp-file>/1001.jsp</jsp-file>
</servlet>

<servlet-mapping>
<servlet-name>smartcardJSP</servlet-name>
<url-pattern>*.jsp</url-pattern>
</servlet-mapping>
------------------------------------------
if it is not possible tell me the alternative way my application has many jsps......so in all jsps i need to access database...
if possible tell me how can i do this with context parameters


Abhishek
Freddy Wong
Ranch Hand

Joined: Sep 11, 2006
Posts: 959

I don't think it's possible. If you want all your JSPs/Servlets to access your init params, why don't you use <context-param> instead?


SCJP 5.0, SCWCD 1.4, SCBCD 1.3, SCDJWS 1.4
My Blog
 
jQuery in Action, 2nd edition
 
subject: mapping all jsps to single servlets init parameters