This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JNDI datasource

 
Aman Singh
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Marshal
Posts: 34084
337
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Aman Singh
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic