File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Spring and the fly likes Objects are not staying permanently after JSP is reloaded in next time. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "Objects are not staying permanently after JSP is reloaded in next time." Watch "Objects are not staying permanently after JSP is reloaded in next time." New topic
Author

Objects are not staying permanently after JSP is reloaded in next time.

Vinod Vijay
Ranch Hand

Joined: Sep 13, 2011
Posts: 137

Hi, on my JSP there is a select box which has some objects pre-populated before the screen is displayed to user for his input. Now what is happending when the user submits the form, it performs server side validations using the Spring Validations and in case some issue is found then redirects to same JSP with the error messages to be displayed on JSP. Now this time the pre-populated objects in my dropdown select box are gone, completely blank. Please tell me what is causing this issue and how to make them permanently available on JSP.

here are my codes:-


I'm setting into model using addAttribute() and on JSP retrieving like this:-


First load of JSP, it is coming and on refresh also it is coming but when a page is submitted or actually processed and comes back then it displays nothing.

Thanks


Vinod Vijay Nair
Stefan Evans
Bartender

Joined: Jul 06, 2005
Posts: 1018
You have some code here that adds attributes into the model.
This happens on the default render request.

Does it run through this code when processing this page?
Or is that a different render request?

Vinod Vijay
Ranch Hand

Joined: Sep 13, 2011
Posts: 137

Stefan Evans wrote:You have some code here that adds attributes into the model.
This happens on the default render request.

Does it run through this code when processing this page?
Or is that a different render request?


Hi Stefan,

Yes! this is default render request method which gets called when my jsp is loaded for first time. And when user submits the form, another method Action request gets called. In that method, it checks server side validations and if something goes incorrect then it redirects to this same default render request method.
Bill Gorder
Bartender

Joined: Mar 07, 2010
Posts: 1648
    
    7

most likely you are not getting in that same handler so your model is not getting populated again, set a breakpoint and see. You could also store it as an @SessionAttributes this way it will stay available for you.

See
http://static.springsource.org/spring/docs/3.1.x/spring-framework-reference/html/portlet.html#portlet-ann-sessionattrib


[How To Ask Questions][Read before you PM me]
 
jQuery in Action, 2nd edition
 
subject: Objects are not staying permanently after JSP is reloaded in next time.