Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Call SQL Script from JSP

 
Albert Hopkins
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi...
I have a sql script called student.sql .

How can I call that script directly using JSP.

Example : Query = student.sql;

thanks

p.s : I hope I'm in the right topic.
 
Tom Johnson
Ranch Hand
Posts: 142
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I had a look at the JSTL sql tags and couldnt see anything how to do this. Possibly the reason is you shouldnt! Better not to have this sort of thing in JSP. I would recommend putting the database access in a business logic code i.e. a java class....
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64696
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tom has it correct. A JSP is no place to be doing SQL access. Write this as a standalone Java class that you could trigger from a JSP if necessary, but do not perform database access in UI classes or JSPs.
 
Scott Selikoff
author
Saloon Keeper
Posts: 4010
18
Eclipse IDE Flex Google Web Toolkit
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This post (along with many like it) inspired me to write a blog article about why adding JDBC to JSP is really bad: http://www.selikoff.net/blog/2009/02/24/why-jdbc-jsp-bad/

Hopefully, it helps explain the issue in detail.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic