aspose file tools
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes scope problems Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Reply Bookmark "scope problems" Watch "scope problems" New topic
Author

scope problems

riohk kurn
Ranch Hand

Joined: Oct 19, 2002
Posts: 31
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

Joined: Oct 27, 2002
Posts: 87
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

Joined: Oct 27, 2002
Posts: 87
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
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: scope problems
 
Similar Threads
Illegal State Exception: Ref Page 412 HF Book
JSP document problem
pasing request from JSP to servlet
forward and include
what is the diff between tomcat 4.1 and 6.0