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

scope problems

 
riohk kurn
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, we all know that those variables in page scope are sharable in both including and included files using static inclusion.
1) However, how about <jsp:forward> action, I think it is not the case.
Owing to the process cycle, we need to use setattribute to pass some variables in <jsp:include> action.
2) if I use pageContext.setAttribute(XXX, page), am I fooling myself. and get a wrong result?
3) Are there any scopes in <jsp:getProperty>?
4) If I take this action <jsp:useBean id="xxx" class="xxx">, and then <jsp:forward page="new.jsp">, can javabean "xxx"'s properties be accessed in new.jsp. Since I only set this bean in page scope.
Thx
 
Maha Annadurai
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dynamic inclusion or forward actions do not have access to page scoped vars of the first 'including' jsp. Meaning,if a.jsp uses <jsp:include ....../> or <jsp:forward ...... /> another b.jsp , then b.jsp can not access a.jsp's page scoped vars like your case. The 'xxx' var is page scoped var and it is invisible in the 'forwarded' jsp.
But the implicit 'request' object is same in both pages. So we can do request.setAttribute(name,value) trick to share objects.

Regards,
Maha Anna
[ November 25, 2002: Message edited by: Maha Annadurai ]
 
Maha Annadurai
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here is the example code I played with.

when you invoke one.jsp , you will get a 500 internal server error like this.

Regards,
Maha Anna
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic