File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/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 EJB 3 in Action this week in the EJB and other Java EE Technologies 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: 136
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: 60049
    
  65

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: 60049
    
  65

Perhaps this JavaRanch Journal article which outlines the life cycle of a JSP might be instructive.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: bean not found within request scope, but session scope
 
Similar Threads
Creating a bean in session scope
jsp:useBean
Basic useBean question
Problems with jsp:useBean
Passing Javabean from JSP to Servlet - null