Re: form bean and session attribute
On May 7, 2:16 pm, "John B. Matthews" <nos...@nospam.invalid> wrote:
In article
<18b4ab4e-7cae-4322-9c27-8355526b4...@d38g2000prn.googlegroups.com>,
Thufir <hawat.thu...@gmail.com> wrote:
On May 4, 6:09 pm, "John B. Matthews" <nos...@nospam.invalid> wrote:
[...]
It's possible to write web applications with no MVC architecture at a=
ll.
They are difficult to maintain, more difficult to grow, and most
difficult to redecorate.
Well, then it appears that JSP setProperty includes a pointless
option, if using <jsp:setProperty name="bean" property="*"/> leads =
to
a MVC violation however you handle the result. This contradicts my
assumption that JSP setProperty conforms/facilitates MVC.
I wouldn't call it a violation. IIUC, using setProperty in the JSP is
common to a Model 1 web tier architecture, while Model 2 reserves this
to a controlling servlet. The former isn't wrong, but the latter has
some distinct advantages. See section 4.4.1 Structuring the Web Tier:
<http://java.sun.com/blueprints/guidelines/designing_enterprise_applicati
ons_2e/web-tier/web-tier5.html>
The Marty Hall slideshow about MVC recommended upthread (14-MVC.pdf,
<http://courses.coreservlets.com/Course-Materials/pdf/csajsp2/14-
MVC.pdf>
suggests that with a Model 2 approach:
The JSP page should not create the objects
=96 The servlet, not the JSP page, should create all the data
objects. So, to guarantee that the JSP page will not create
objects, you should use
<jsp:useBean ... type="package.Class" />
instead of
<jsp:useBean ... class="package.Class" />
The JSP page should not modify the objects
=96 So, you should use jsp:getProperty but not jsp:setProperty.
--
Lew