File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes JSP and connection with Database Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "JSP and connection with Database" Watch "JSP and connection with Database" New topic
Author

JSP and connection with Database

Ramesh Subramanian
Greenhorn

Joined: Oct 03, 2000
Posts: 13
Hello,

How to connect Applet-JSP-Database?
or
Applet-JSP-servlet-Database?
Can any one pl tell me with example code? or tell me the site from which i can get more idea about this?
Thanks in Advance,
Ramesh
Desai Sandeep
Ranch Hand

Joined: Apr 02, 2001
Posts: 1157
Hi Ramesh,
You would find lots of information on how to connect the Applet/JSP/Servlet to the Database in various books available in the market.You may refer to Pure JSP By James Goodwill for some examples.
There is nothing tricky about this.You can access DB using the usual JDBC steps, viz. creating a connection, creating a statement,creating a resultset and iterating through it.
If you are using the Applet-Servlet-DB architecture, write the JDBC code in the Servlet and that too in the init() (or I suggest you use Connection Pooling..Pure JSP has an example for it) for performance benefits.
If you are using the Applet-JSP-DB architecture, write the JDBC code in the JSP.You may consider writing the JDBC calls in the JavaBean and create an instance of the bean using the <jsp:usebean> tag.
Hope this helps.
Regards,
Sandeep Desai
vgdesai@bom3.vsnl.net.in

  1. Sun Certified Java Programmer Scored 93 per cent
  2. Oracle JDeveloper Rel. 3.0 - Develop Database Applications with Java Scored 56 out of 59
  3. IBM Enterprise Connectivity with J2EE Scored 72 per cent
  4. Enterprise Development on the Oracle Internet Platform Scored 44 out of 56

  5. [This message has been edited by Desai Sandeep (edited April 25, 2001).]


<b>Sandeep</b> <br /> <br /><b>Sun Certified Programmer for Java 2 Platform</b><br /> <br /><b>Oracle Certified Solution Developer - JDeveloper</b><br /><b>-- Oracle JDeveloper Rel. 3.0 - Develop Database Applications with Java </b><br /><b>-- Object-Oriented Analysis and Design with UML</b><br /> <br /><b>Oracle Certified Enterprise Developer - Oracle Internet Platform</b><br /><b>-- Enterprise Connectivity with J2EE </b><br /><b>-- Enterprise Development on the Oracle Internet Platform </b>
Santosh Jaiswal
Greenhorn

Joined: Oct 04, 2000
Posts: 26
Can you please tell me which one is better?
Applet-Servlet-DB architecture or Applet- JSP - architecure
Thanks
Santosh
Andrew Shafer
Ranch Hand

Joined: Jan 19, 2001
Posts: 338

Santosh,
JSP's are compiled into servlets so these are functionally equivalent.
Assuming your applet takes care of the view, you might see some performance benefit with pure servlets in some applications.


!_I_Know_Kung_Fu_!
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: JSP and connection with Database