aspose file tools*
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
Author

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
internet detective
Marshal

Joined: May 26, 2003
Posts: 29244
    
139

Aman,
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.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, 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
 
Similar Threads
wsad and oracle -SOS
Access Server's Datasource from standalone
Is javax.sql.DataSource a costlier resource like java.sql.Connection?
NoInitialContextException
How to use configured datasource