File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes Connecting to a server Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Connecting to a server" Watch "Connecting to a server" New topic

Connecting to a server

Nirmala Dhara

Joined: Sep 05, 2005
Posts: 4

I am new to struts and I want to create a web interface to my database application. Once I login, I need to conncet to my server and it should be available to all my action classes. Where should I create connection to my database server? and How?

Thank you very much,
Stefan Evans

Joined: Jul 06, 2005
Posts: 1580
You should set up a JNDI datasource.
Most applications servers will do that for you.
Here is the link for the Tomcat docs:

Also, Struts purists will insist that your action should not contain any connections to a database. That responsibility belongs to another layer.
Check out the
Data Access Object pattern
Nirmala Dhara

Joined: Sep 05, 2005
Posts: 4
I also need to connect to backend server on Nonstop platform. From logon screen I get IP and port for it. Should I use JNDI for this type connection?

I agree. Here's the link:
subject: Connecting to a server
It's not a secret anymore!