This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
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 OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Database connection from jsp" Watch "Database connection from jsp" New topic
Author

Database connection from jsp

goli reddy
Greenhorn

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

Joined: Mar 08, 2007
Posts: 1585
Hi,

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: 3350

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: 3350

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

Joined: Sep 02, 2007
Posts: 8
thanks now i got it
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Database connection from jsp