If you want to avoid a typical MVC structure and having all your logic in
Servlets instead of JSP files (which is what I would suggest you do), you
can abstract your database accesses in classes that do all the work and only
have the class method calls within our JSP code.   That way you do not need
to have the database implementation code visible in the JSP and you can
reuse the classes in multiple JSP files.   Create all the database access
classes in a package and include that package in each JSP.  It is not as
well structured as a MVC type of structure but it does a reasonable job of
isolating your database access from the JSP.   If you create your classes
properly you can make your JSP code independent of the database being used
and thus allow it to be very portable.   You can also make the classes
centered around functionality as opposed to being table specific, thus
granting you more freedom for future modifications.

This will keep the object oriented design valid without having to use MVC.
However, it is an inferior approach and should be used with caution and only
in simple applications.



-----Original Message-----
From: A mailing list about Java Server Pages specification and reference
[mailto:JSP-INTEREST@;JAVA.SUN.COM]On Behalf Of rvt
Sent: Friday, October 18, 2002 8:25 AM
To: [EMAIL PROTECTED]
Subject: [JSP-INTEREST] Database Access Using Tags


Hi,

I seem to recall reading on one of the user lists (maybe this one) that
using taglibs for connecting to the database was not a good idea, for
security reasons.  The consensus was that it was at least better than
embedding Java scrptlets in your JSP.

I've been scouring the Net trying to figure out the best way to get a
database connection.  I'm using JSPs for the view, but I want to keep as
much Java code out of the pages as possible, since that results in a much
cleaner and easier to maintain application.  But I'm a newbie when it comes
to model 2.  I've written a site before using just JSP with Dreamweaver UD4.
But with what I'm working on now, that is not good enough.

I've got Tomcat set up, and I'm trying to use connection pooling.  I know
that I can use JNDI and Tomcat to look after the connection pooling details,
though I'm tearing my hair out trying to figure out how it all works and if
I've got all the pieces in place that I need.

My question/plea for input here is regarding what I should be using to write
the actual connection in.  If tags are not recommended, then should I be
using a class, a bean, or a servlet to do that work?  I read recently (I've
been doing a LOT of reading) that tags are a replacement for beans--though
that sort of conflicts with the point that I read before that tags are only
one step up from using scriptlets.  I'm starting to conclude that I should
be using a servlet, but I would really appreciate some confirmation from
people who are experienced with all this.

Also, is it possible/necessary to try to make the structure of the Web
application object oriented?  If I'm using JSP, does that negate the need
for creating an object oriented design--does it make that kind of a design,
even though I'm using Java, impossible to really do?

Thank you for any input.  I'm trying to get all these concepts straight in
my head, and the information out there is not only conflicting, but a little
overwhelming.

Val

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST
DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://archives.java.sun.com/jsp-interest.html
 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.jsp
 http://www.jguru.com/faq/index.jsp
 http://www.jspinsider.com

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://archives.java.sun.com/jsp-interest.html
 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.jsp
 http://www.jguru.com/faq/index.jsp
 http://www.jspinsider.com

Reply via email to