Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / Tools / October 2003

Tip: Looking for answers? Try searching our database.

Tomcat configuration: Parameters/contexts

Thread view: 
Sean Clarke - 10 Oct 2003 15:28 GMT
Hi,
       Is it possible to configure a set of parameters for all servlets in a given
context?

Say I have 2 servlets in a context A and B:

<servlet>
   <servlet-name>A</servlet-name>
   <servlet-class>A</servlet-class>
   <init-param>
       <param-name>db</param-name>
       <param-value>TestDB</param-value>
   </init-param>
</servlet>
<servlet>
   <servlet-name>B</servlet-name>
   <servlet-class>B</servlet-class>
   <init-param>
       <param-name>db</param-name>
       <param-value>TestDB</param-value>
   </init-param>
</servlet>

This obviously get's a bit out of hand (I'd like to avoid a property file).

What I want to say is "For all servlets in this context db = TestDB"?

Signature

Regards

Sean Clarke
-------------------------------------------------
Linux.... for those whose IQ is greater than 98 !!

Neil Green - 10 Oct 2003 15:44 GMT
>         Is it possible to configure a set of parameters for all servlets in a given
> context?

[snip]

> What I want to say is "For all servlets in this context db = TestDB"?

How about

<web-app>
...
   <context-param>
       <param-name>db</param-name>
       <param-value>TestDB</param-value>
    </context-param>
...
</web-app>

to set the parameter for the context.

Then using getServletContext().getInitParameter( "db" )

HTH
Neil


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.