On 1/17/2001 at 2:05 PM Mahesh Chhatlani wrote:
> I just want to know the most "efficient" and "professional" way.
I'm not sure efficient and professional are always the same thing when
it comes to programming ;0), but ...
The database query would count as business logic. The accepted wisdom
now is that business logic should not be a part of the "view" (your JSP
page).
It should be encapsulated in something that you could reuse, and,
ideally, something that you could use in another environment (e.g.
Swing).
In the end, you probably want a servlet that in turns uses a JavaBean
(or two, or three) to talk to the DBMS, and return the result to a JSP
in the request context, in some sort of collection. (Or, if you are
very clever, in a rowset ;0).
You might want to look for more about Model 2 and Model-View-Controller
design model.
The Struts 1.0 User Guide < http://jakarta.apache.org/struts > goes
into it, and I have a new preface to that at <
http://husted.com/about/struts >, called "A Brief History of Struts".
Within this model, even things like your quick login checks should be
encapsulated in something that doesn't involve Java code, like a custom
"CheckLogin" tag. The Struts Example application uses one of these.
*********** REPLY SEPARATOR ***********
Thanks for the tips,
But to be more clear on this subject, say I want to write a new web
application in JSP. Now I have to create a detail page where there will
be 2
or more queries(with joins) to fill up the page. Now should I use a
JavaBean
to have the query and logic to get data from the database and send the
results to the JSP page, or have a Servlet do the above. Consider that
BOTH
options have the same network traffic, both are on the same server,
etc.(like comparing apples to apples) I know "how" to do it, I just
want to
know the most "efficient" and "professional" way. Or does it matter
either
way? I know that option (1) is not the right way to do it. But for a
Login
check(uid/pwd), is it okay?
Thanks.
--mahesh
PS: I get the feeling that option(2) is the right one....
***********************************************
> Hi,
> Which is the "suggested" way to access the database, say for
> an intermediate
> query that throws out about 100 rows.
>
> (1) JSP to db directly on a JSP page
> (2) JSP to JavaBean (where the bean has all the db access)
> (c) JSP to Servlet (where the Servlet accesses the db)
>
> For quick login checks, etc I use the 1st method.
> What about queries that throw out more than 1000 rows? Which
> method is the
> "suggested" one?
> Thanks.
> --mahesh
>**********************************************
========================================================================
===
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://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets
===========================================================================
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://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets