Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Database connection from jsp

 
goli reddy
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hai
how we connect to database from jsp.is it good practice through jsp
 
Vassili Vladimir
Ranch Hand
Posts: 1585
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Do you know JDBC ?

Best regards ...
 
Raghavan Muthu
Ranch Hand
Posts: 3381
Mac MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Raghavan Muthu
Ranch Hand
Posts: 3381
Mac MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's a very good and crisp reply with the appropriate figure Stan.
 
goli reddy
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks now i got it
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic