Is it a good idea to use the 'Resultset' class from a bean in a JSP page ?

-----Original Message-----
From: Starsinic Frank [mailto:[EMAIL PROTECTED]]
Sent: Friday, November 12, 1999 5:55 PM
To: [EMAIL PROTECTED]
Subject: Re: JDBC from JSP


>From a theoretical sense, there should (in my opinion) not be too many
"JDBC in a JSP page" examples out there.

JDBC should be done in a Java Bean, perhaps, and then the JSP page can do
the
<jsp:useBean > tag to gain access to the JDBC by proxy.

>From a good architecture point of view, JDBC should not be done in a JSP
page.

Comparing, JSP to ASP, i think this is where you will find JSP to be quite
superior.

This helps keep the code out of the JSP....

Keeping that in mind, here is some example code where the bean does the JDBC
and
the JSP page hardly does anything at all.  This example shows how an
Application
Bean
is used to Cache database table info for the jsp application ...

Notice how the <select> box is populated via one method call to the
ReferenceClientBean Bean.
Also, in this case, the method also excepts an "id" parameter and makes that
<option > SELECTED automatically.

The "beans" both connect to the database  as RMI clients to an RMI server
that
does
the real connecting to the database.

I realize that there are no JDBC calls in the JSP here, so you might be
pissed,
but I feel that
this is the preferred method of developing a JSP application. It separates
Code
form HTML
and also keeps your database code in one layer, middle tier stuff in another
layer, etc. etc.

One key benefit of this approach that is implemented is that the Bean caches
all
the tables
in a hashtable, so the next time somone needs this info, it is looked up in
cache instead of
the database.

############################# START OF
JSP#######################################
<jsp:usebean id="sqlRefTables"    class="ReferenceClientBean"
scope="application"/>
<jsp:usebean id="sqlUserTable"    class="UserBean" scope="application"/>


<% user.loadUser(request.getParameter("idno")); %>

<LOTS_OF_MISSING_HTML>
<form method=post>

<table border=0 cellpadding=1 cellspacing=0 bgcolor=gold>
 <td>Employee # <input name=employeeID
value="<%=sqlUserTable.getEmployeeID()%>"
 length=10 maxlength=30></td><td>&nbsp;</td>

 <select name=job_title_k>
  <%=
sqlRefTables.getHTMLReferenceList("REF_LA_JOB_TITLE",sqlUserTable.getJobTitl
eKey().toString())%>
  </select>

  <select name=access_type_k>
   <%=
sqlRefTables.getHTMLReferenceList("REF_LA_BRANCH_TYPE",user.getBranchAccessT
ypeKey().toString())

%>
  </select>
</LOTS_OF_MISSING_HTML>
############################# END OF
JSP#######################################






Sudha Gopalakrishnan <[EMAIL PROTECTED]> on 11/12/99 01:05:41 PM

Please respond to Sudha Gopalakrishnan <[EMAIL PROTECTED]>

To:   [EMAIL PROTECTED]
cc:    (bcc: Frank Starsinic/TMS)

Subject:  JDBC from JSP


Hi,

Can someone point me to an example where you do
database connecctivity from a JSP page. ( Like you use
ADOs in ASPs, what is the equivalent in JSPs?)

Thanks,
sudha

__________________________________________________
Do You Yahoo!?
Bid and sell for free at http://auctions.yahoo.com

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
JSP-INTEREST".
FAQs on JSP can be found at:
 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
JSP-INTEREST".
FAQs on JSP can be found at:
 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
FAQs on JSP can be found at:
 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html

Reply via email to