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 / General / October 2007

Tip: Looking for answers? Try searching our database.

Tomcat and web.xml

Thread view: 
Chris ( Val ) - 06 Oct 2007 17:02 GMT
Hi all,

Lets say I want to include some 'context' parameters for database
access as follows:

<context-param>
   <param-name>DriverClassName</param-name>
   <param-value>oracle.jdbc.driver.OracleDriver</param-value>
</context-param>

<context-param>
   <param-name>JdbcURL</param-name>
   <param-value>jdbc:oracle:thin:@localhost:1521:XE</param-value>
</context-param>

I obtain their values via the "getInitParameter(...)" method of the
application.

I have seen them used in both the Tomcat global 'web.xml' file
in the 'conf' directory, and also in the 'web.xml' file local to each
deployed application.

Is there a diffinitive answer on which is the best place do put
these parameters?

Also, is this form of database access still used, or is a databse
connection pool the preferred way?

If so, when is this kind of method used?

Thanks,

Chris
Lew - 06 Oct 2007 19:01 GMT
> I have seen them used in both the Tomcat global 'web.xml' file
> in the 'conf' directory, and also in the 'web.xml' file local to each
> deployed application.
>
> Is there a diffinitive answer on which is the best place do put
> these parameters?

The same as for all "global vs. local" decisions: put information into a
global location if it's used by everything, put in a local location if it's
used only for that location.

> Also, is this form of database access still used, or is a databse
> connection pool the preferred way?

A database connection pool can be set up in exactly the same way, via context
parameters in the web.xml.  It is an orthogonal issue.

> If so, when is this kind of method used?

I am unable to parse the antecedents for "so" or "this" in this question.

Signature

Lew

Chris ( Val ) - 07 Oct 2007 11:18 GMT
> > I have seen them used in both the Tomcat global 'web.xml' file
> > in the 'conf' directory, and also in the 'web.xml' file local to each
[quoted text clipped - 6 lines]
> global location if it's used by everything, put in a local location if it's
> used only for that location.

Ok, I can understand that line of reasoning.

> > Also, is this form of database access still used, or is a databse
> > connection pool the preferred way?
>
> A database connection pool can be set up in exactly the same way, via context
> parameters in the web.xml.  It is an orthogonal issue.

Can you expand on that a little please?

Do you mean that I can I still use the "getInitParameter(...)"
method of the application object using a connection pool?

> > If so, when is this kind of method used?
>
> I am unable to parse the antecedents for "so" or "this" in this question.

Sorry. The 'this' above was relating to whether 'connection pooling'
was
the prefered way of obtaining a database connection over the previous
one
I presented.

Is there a preference?

At the moment I have all the code in a JSP for learning, but I imagine
that it should ultimately go into a servlet or Java Bean, right?

Thanks for your help.

Chris
Lew - 07 Oct 2007 16:45 GMT
Lew wrote:
>> A database connection pool can be set up in exactly the same way, via context
>> parameters in the web.xml.  It is an orthogonal issue.

> Do you mean that I can I still use the "getInitParameter(...)"
> method of the application object using a connection pool?

Yes.

> Sorry. The 'this' above was relating to whether 'connection pooling'
> was
> the prefered way of obtaining a database connection over the previous
> one
> I presented.

Usually.  Connections fall into one of three basic types: single connection
created on demand, connection pool, "XA" (transaction-aware) connection.  The
difference is in which driver you use.

> At the moment I have all the code in a JSP for learning, but I imagine
> that it should ultimately go into a servlet or Java Bean, right?

Correct.

A servlet receives the request, parses it and farms it out to beans for
processing, collects a status, and forwards (RequestDispatcher forward()
method) to a JSP for presentation of the results.

Signature

Lew

Chris ( Val ) - 07 Oct 2007 17:56 GMT
> Lew wrote:
> >> A database connection pool can be set up in exactly the same way, via context
[quoted text clipped - 23 lines]
> processing, collects a status, and forwards (RequestDispatcher forward()
> method) to a JSP for presentation of the results.

Thanks Lew,

It's beginning to make sense, and I appreciate your help :-)

Chris


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.