• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Question on Standard actions

 
Priya Jothi
Ranch Hand
Posts: 168
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

Plz clarify my doubt for the following question.

<jsp:usebean id="person" type="foo.employee">
<jsp:setProperty name="person" property="name" value="fred"/>
</jsp:usebean>
<jsp:getProperty name="person" property="name"/>

1)foo.person p = new foo.employee();
p.setName("Evan");
request.setAttribute("person",p);

2)foo.employee p = new foo.employee();
p.setName("Evan");
request.setAttribute("person",p);

In HFSJ,it is given that the first servlet & JSP pair wont work because usebean action will search the "person" in page scope since the scope attribute is missing in the usebean action and it defaults to "page".
Whereas the actual "person" object available only in request scope.I totally agree with this.But it is also given that the third servlet & JSP pair will work & print "Evan".How it is possible?.Here also "person" is set in the request scope & it should also fail right?.I dont understand the difference.Would request someone to clarify.

Thanks in advance..

Regards,
Priya.
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't own the book, so I don't know which page it is,
but looking at the errata,
I found this :

[416] Be the Container Answers;
The third example will not work for the same reason that the first example doesn't
work, because the attribute is at Request Scope, and the default scope is Page scope.
The handwritten comment for bullet #3 should be the same as for bullet #1.

Wouldntt that be your problem ?
 
Priya Jothi
Ranch Hand
Posts: 168
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Satou!!.Now it is clear!!!

Regards,
Priya.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic