Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Standard action query

 
Seema Ahuja
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
I have not understood the following concept in chapter number 8 please can someone explain to me why it works in one situation and fails in another?



why does it fail for the above servlet code? and pass for the one below? when both the servlets set the attribute in request scope and looking at the standard action we can tell that the bean property is set for Pagescope?
also for information erson is the super class of employee where person is an abstract class and person a concret implementation of person.
also we know that we cannot create an object when class attribute is not specified in the statndard action.

2.

i am really confused.will someone please explain it to me?

Thanks
Seema.
 
Dinuka Arsakularatne
Ranch Hand
Posts: 198
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
it is because in the sevlet you specify the type as foo.person but in the standard action you have specified the type as foo.employee. so it cannot create one for you too because you have only type specified in the standard action.
 
Seema Ahuja
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So is it because of the difference between the type thats been createdin the servlet and the one specified in statadrad action?!
but how does it get reference to the attribute when v have set it in request scope and the statndard action sets the type in page scope?!
how does it work??
am still not clear?!
 
Dinuka Arsakularatne
Ranch Hand
Posts: 198
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
well basically when you dont specify the scope explitly, it does default to page scope. but if you see the generated servlet in tomcat, you can see that it includes it as pageContext.findAttribute(...); so that means that all four scopes will be searched starting from page, request,session and lastly application. the first scope that has that name wins. it basically search from the most restrictive scope to the least restrictive scope...
 
Gowher Naik
Ranch Hand
Posts: 643
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
it is because in the sevlet you specify the type as foo.person but in the standard action you have specified the type as foo.employee. so it cannot create one for you too because you have only type specified in the standard action.

if type matters then how code below works

out put of above code is-: Evan1
 
Bachi Taurean
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the <jsp:setProperty> code fragment which sets the value of name as Fred will not get executed since there is already a bean called person existing in request scope, so jsp:useBean fails. So, the name 'Evan1' remains as the value of the name property.
 
Seema Ahuja
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
but the question remains...if the type matters how come the types din't clash this time?? as in the servlet the type is specidfied as " Person" and in the <jsp:useBean> we are specifying the type as Employee???
where as the code that was put up by me earlier fails!!
Not convinced that its because of type that the pervious code failed.....please explain
 
Arvind Giri
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Refer to errata :

[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.


But seems like this is not the only problem. Even after specifying scope="request", it is giving me following error(I am using Jboss).



So It seems jsp:setProperty does not work if we only specify type attribute in jsp:useBean(and Logically it should not work but I didn't find anything regards this in JSP specs that it should give compile time error).

Ranchers, what do you say ?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic