jQuery in Action, 3rd edition
The moose likes EJB and other Java EE Technologies and the fly likes JNDI datasource Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "JNDI datasource" Watch "JNDI datasource" New topic

JNDI datasource

Aman Singh
Ranch Hand

Joined: Oct 30, 2008
Posts: 57
hi all,
I am using Websphere 6.0 and I am able to create a jndi datasource through admin console and gave it a name jdbc/asm_met. Now can anyone please tell me the code how to access this datasource in a jsp page. I want to use JSTL for running the queries.
Please provide me the detail code for accessing it through my jsp.
Jeanne Boyarsky
author & internet detective

Joined: May 26, 2003
Posts: 33124

Don't you just pass the Datasource name into the JSTL tag as shown?

Note that it is bad practice to do database from the JSP layer. JSPs are for presentation. You would be better served calling the database from a servlet (or class called by the servlet) before forwarding to the JSP.

[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
Aman Singh
Ranch Hand

Joined: Oct 30, 2008
Posts: 57
Hi Jeanne,
Thanks for your reply. The example you gave me is for tomcat server, where we specify the JNDI sources in server.xml file. I am using Websphere and made the JNDI resource using the admin console. Now Do I just need to call it using the datasource name ?

Another question. Please tell me how to work this stuff with thr use of servlet. Should I make a jdbc connection using a servlet? if so then how do I pass that connection to my JSP? please help me out with this.. I am new to all this.
I agree. Here's the link: http://aspose.com/file-tools
subject: JNDI datasource
It's not a secret anymore!