• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

bean not found within request scope, but session scope

 
Yan Zhou
Ranch Hand
Posts: 137
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there,

I have A.jsp that creates a request scope bean and a form.



A servlet responds to form submit, and the servlet simply forwards the request to B.jsp, which uses the request scope bean.



I am getting error "bean my not found within scope". However, if I change the scope to "session", then everything works.

What I do not understand is why "request" scope does not work since both A and B are on the same request. As I debug the doGet() method of the servlet, I noticed that there is no attribute in the HttpServletRequest object parameter of doGet(), should not there be the bean I just created?

What am I missing?
Thanks.
Yan
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64990
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What I do not understand is why "request" scope does not work since both A and B are on the same request.


They are not in the same request. The first request ends when A is sent to the browser. The second request, in which you are noticing that no request attribute is available, is created when the form is submitted.
[ October 31, 2005: Message edited by: Bear Bibeault ]
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64990
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Perhaps this JavaRanch Journal article which outlines the life cycle of a JSP might be instructive.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic