You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by "Cato, Christopher" <cc...@rational.com> on 2001/10/19 14:17:42 UTC

Beans howto?

Hello. I'm trying to learn how to use beans in my j2se application. Can
someone show me a simple example of how to use a bean for displaying
database records on a JSP page?

What's preferred? - Using JSP, Servlets and Beans together or just Servlets?


What I don't like about Servlets is sticking all the HTML code in them and I
just don't know how to pass resultsets to JSP pages for display.... :)
Examples, someone?

Have a great weekend guys!

Regards,

Christopher Cato

Re: Beans howto?

Posted by Shiv Kumar MN <sh...@majoris.com>.
Hello,

>>
>> What's preferred? - Using JSP, Servlets and Beans together or just Servlets?
>>

It is a tough question to answer, each one us have our own
reasons/justifications
to use a particular technology/language. I wanted to clarify one point here,
that is
it is NOT required to have any of HTML code in Servlets. Having HTML in
servlet is very bad and just not right way of developing. You can still develop
an
application using servlets (completely of servlets!!) using what is called
"Template
Engines". There is one open source engine called Freemarker on
www.SourceForge.net.
I know couple of more template engines: Velocity from Apache-Jakarta and
www.webmacro.org but I have not used them.

The advantage of these approach is:
In JSP, you will have Java code in your HTML (one of the reason why you use
JSP is to avoid HTML inside Java code, but you are doing it reverse in JSP).

For more details you can see:
http://www.servlets.com/soapbox/problems-jsp.html

Two major commercial web applications developed by our company using this
approach is running smooth on the net on Apache/Tomcat v3.2.

Cheers,
 - Shiv.

"Cato, Christopher" wrote:

> Hello. I'm trying to learn how to use beans in my j2se application. Can
> someone show me a simple example of how to use a bean for displaying
> database records on a JSP page?
>
> What's preferred? - Using JSP, Servlets and Beans together or just Servlets?
>
> What I don't like about Servlets is sticking all the HTML code in them and I
> just don't know how to pass resultsets to JSP pages for display.... :)
> Examples, someone?
>
> Have a great weekend guys!
>
> Regards,
>
> Christopher Cato