Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

JspException: Failed to obtain specified collection

Status
Not open for further replies.

liorza

Programmer
Mar 3, 2004
27
US
Hi all,
I am getting this error when moving between jsp pages in my web application.
The scope of my actions is "request". If I change the scope to be "session" this error goes away. I think I should use "request" scope in my web app and that is why
I am trying to understand why & when struts is throwing this error. I am trying to have a better understanding before I try to fix it.

Thanks
Lior


 
When you saying moving between JSP pages, do you mean

a) a JSP forward,
b) a JSP sendRedirect,
c) or simply user go to another page.

Only a) forward is still within the same request scope. b and c is a different request from user, and previos request is considered done and all request scope data are discarded.
 
I am doing a JSP forward.
I am getting this when validate is set to true and
the validation fails.

Lior
 
I believe the problem is that the collection is set in a Action class that forward to the form page. However, when the form is submitted, a new request is send (a new request scope), which handle by a form Action for validation. If validation failed, the form Action forward back to the form JSP. This time, the collection is no longer there as it is a different request scope. Assuming you have a form action class for the form, solution would to set the colletion in the form action class if validation failed.

Follow show how form submit is in a different request scope

(request scope begin) (request scope end)
--->Action(set collection)-->form.jsp

(request begin) (request end)
form.jsp-->formAction-->action-->sucess JSP
^ |
| |(vailation failed)
| |
+-------<------+
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top