jQuery in Action, 2nd edition*
The moose likes JSP and the fly likes Database connection from jsp Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Database connection from jsp" Watch "Database connection from jsp" New topic

Database connection from jsp

goli reddy

Joined: Sep 02, 2007
Posts: 8
how we connect to database from jsp.is it good practice through jsp
Vassili Vladimir
Ranch Hand

Joined: Mar 08, 2007
Posts: 1585

Do you know JDBC ?

Best regards ...

Vassili ...
SCJP 5.0, SCWCD 1.4, SCJA 1.0
Raghavan Muthu
Ranch Hand

Joined: Apr 20, 2006
Posts: 3344

Hi goli reddy,

For your first part of the question, Vassili has answered you by asking a question

For the second part, NO. Its not a good practice unless you are NOT doing a standard application which is compliant to J2EE standards.

Though it is legal, it is NOT right.

Does that help you?

Everything has got its own deadline including one's EGO!
[CodeBarn] [Java Concepts-easily] [Corey's articles] [SCJP-SUN] [Servlet Examples] [Java Beginners FAQ] [Sun-Java Tutorials] [Java Coding Guidelines]
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
It's good to move database access into a set of classes that are separate from JSPs. This kind of thing is common and is sometimes called MVC2:

The Servlet acts as a controller. It pulls data out of the HttpRequest and figures out what POJO to call. A "Plain Old Java Object" is not part of any framework, and I like them to have no J2EE imports at all - no session or request or response. The POJO can read or write databases or whatever it needs to do and return data for the next page. The controller forwards to a JSP which formats the response and does nothing else.

Does that make sense?

A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
Raghavan Muthu
Ranch Hand

Joined: Apr 20, 2006
Posts: 3344

That's a very good and crisp reply with the appropriate figure Stan.
goli reddy

Joined: Sep 02, 2007
Posts: 8
thanks now i got it
I agree. Here's the link: http://aspose.com/file-tools
subject: Database connection from jsp
Similar Threads
hi everybody me Epsan new to this Forum,to Java
JSP Value retrival
create a excel sheet fom java and jsp
db to jsp
How can i randomly viewing image on jsp from the database