aspose file tools*
The moose likes JSP and the fly likes bean not found within request scope, but session scope Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "bean not found within request scope, but session scope" Watch "bean not found within request scope, but session scope" New topic
Author

bean not found within request scope, but session scope

Yan Zhou
Ranch Hand

Joined: Sep 02, 2003
Posts: 137
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

Joined: Jan 10, 2002
Posts: 61434
    
  67

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 ]

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61434
    
  67

Perhaps this JavaRanch Journal article which outlines the life cycle of a JSP might be instructive.
 
jQuery in Action, 2nd edition
 
subject: bean not found within request scope, but session scope