Hi Keith
If you are using the bean approach. Passing data from the page is very
simple and quick an example:
<jsp:useBean id="ReportBean" scope="request" class="MyPackage.MyBean"/>
<jsp:setProperty name="ReportBean" property="rowDisplayCount"
param="sle_size"/>
The nice thing about this is the Param field directly takes the
output from your query string/ form data being posted to your page
and send the data straight to your bean property.
In fact if you name your property in the bean to match the form field
exactly you
can rewrite the above to look like this
<jsp:useBean id="ReportBean" scope="request" class="MyPackage.MyBean"/>
<jsp:setProperty name="ReportBean" property="sle_size" />
Also note there is wild card approach so I can rewrite once more as the
following
<jsp:useBean id="ReportBean" scope="request" class="MyPackage.MyBean"/>
<jsp:setProperty name="ReportBean" property="*" />
and if you all your form fields name match to your bean property names
This will pump all of the form/query data straight into your bean.
You can also rewrite these to look like the following
<jsp:useBean id="ReportBean" scope="request" class="MyPackage.MyBean"/>
<jsp:setProperty name="ReportBean" property="rowDisplayCount"
param="sle_size"/>
</jsp:useBean>
The difference in syntax being that the properties are being sent to the
bean during
JSP pages initialization of the bean
Now I prefer using the first approach since I like being able to see
on my page what�s going in my bean , I find it easier to debug when I can
see everything happening, the wildcard approach can be dangerous since you
are assuming everything you need is aligned and this can make debugging
problems
harder.
************************************************************************
Now which approach is better in JSP design. They are both good.
My preferences are base upon available resources and complexity of the web
site.
SO when I am the only Java developer, or when the customer
is light on the Java approach. I like to use beans and JSP. I can
make the beans quickly. They are easy to plug in and out
of your JSP pages. I also prefer this approach on smaller simple sites
since you won't have a huge number of beans to maintain / juggle
If I have access to several serious Java developers then switching
to a more centralize servlet system to handle your site will give you
more options in your site I feel. For extremely Large Sites and More
complicated
processing the servlet approach would be better. With the centralize
servlet approach you can optimize your site to a greater degree and reuse
more
elements and have a finer degree of control on how your site is being
processed.
Now I must also admit I prefer to program smaller sites SO I currently stick
to the first approach.
Casey Kochmer
WWW.JSPInsider.com
[EMAIL PROTECTED]
>From: keith kwiatek <[EMAIL PROTECTED]>
>Reply-To: A mailing list about Java Server Pages specification and
> reference <[EMAIL PROTECTED]>
>To: [EMAIL PROTECTED]
>Subject: Can you access servlet info through jsp bean?
>Date: Sun, 9 Jul 2000 10:15:53 -0400
>
>Hello,
>
>Pardon the newbie question, but as I understand it, when designing jsp
>applications, you have two options:
>1) call the jsp page directly, and then reference a bean
>2) call a servlet that instantiates the bean for display in a jsp page.
>
>Off-hand I think I like option 1 best, call the jsp page, which references
>a bean. I like the idea of putting everything in a "bean framework" that
>can then be used by the HTML people....
>
>QUESTION: Using option #1 above, it seems that I must put all the servlet
>environment stuff into the jsp page (session, get/post).... Is this
>correct? Can someone show me how to put it into a bean that can then be
>referenced by the JSP? Is this a good design? If not, what is?
>
>Thanks for any and all help,
>Please post and/or email me [EMAIL PROTECTED]
>Keith
________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com
===========================================================================
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