> -----Original Message-----
> From: babita malani [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, March 07, 2000 12:53 AM
> To: [EMAIL PROTECTED]
> Subject: bean or java code
>
>
> hello everybody,
>
> i have question,
>
> i have made a bean, and used it in a jsp.
> then i made another jsp in which i put java code for get the
> functionality provided by the bean in the previous page.
> both worked well.
>
> Now my question is, which way of doing things is better and why?
> what i presume is that second one is better , as it would be
> faster, since bean does not have to be searched and all.
depends on what your definition of "better" is. if your
desire is for easily changing functionality of the page with
no manual recompilation of code on your part (the JSP engine
would take over), then stick code in the page. your definition
of "better", from your statements above, would seem to be
"faster to execute". have you done benchmarking of both your
methods to determine which is "better"?
however, my view (shared by many others, i'm sure) is that
the purpose of JSPs or any such technology is to assist in
achieving maximal separation of the generation of content
from the display of content. content (without markup language
tags) is generated by a servlet, possibly (probably) with the
help of other back-end entities like databases, and forwarded
on to a JSP so that it can take care of display concerns.
one way to achieve that separation is to keep your content
in beans, to be used in the midst of markup language tags.
this also has the benefit of allowing java developers to stick
with java coding, and allows the introduction of web
professionals (who may not know java) to your team to handle
presentation concerns in the JSP. all they need to know is
the beans used and how to manipulate them via JSP tags.
the degree to which JSP facilitates such separation is a
topic of much debate, but in most cases, i don't think you can
go very wrong by sticking with beans to the degree that you can,
and minimizing the amount and length of scriptlets in your JSPs.
i also doubt that such separation, using JSP, will ever be
truly complete. but you can get pretty far.
i hope this is useful to you.
cheers,
p
--
// Paul Holser -- mailto:[EMAIL PROTECTED]
// ObjectSpace, Inc. -- http://www.objectspace.com
// 14850 Quorum Dr. Ste. 500, Dallas TX 75240 USA
// 972.726.4560 -- 1.800.OBJECT1 x4560
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
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