• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

how can i acces database using jsp?

 
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi friends,
im new to jsp. i want to access database and display the result in the jsp page. how can i do that?

is there anw way to access it without calling the bean?
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can work directly with a database from your JSPs but it is not recommended. Moving the database code out of your servlet and into a bean or some other Java class makes it much easier to test and re-use.

That being said, perform a Google search for "JDBC TUTORIAL" and you will find plenty of code samples.
 
K Vidhyakar
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks a lot..
wil i be able to call a normal class from any jsp file?
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by K Vidhyakar:
thanks a lot..
wil i be able to call a normal class from any jsp file?



If by normal class, you mean a packaged java class that is made available to the web application (in either WEB-INF/classes, WEB-INF/lib, or one of the shared directories), yes.
 
author and cow tipper
Posts: 5009
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can do regular JDBC in a JSP page, but it will get messy, and maintaining that code will be difficult. If it's all proof of concept stuff as you're learning, I guess it's okay.

Here's a little tutorial on MVC and how JSPs should fit into a proper application design. You might find it interesting:

http://www.technicalfacilitation.com/get.php?link=whatismvc

Cheers!

-Cameron McKenzie www.pulpjava.com
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic