I want to be able to pass an object to jsp from one action class and then when user perform some action I want to be able to get that object. How di I do that. I tried using html:hidden tag but it gives me an "Illegal Argument Exception Null Value for 'MyObject'.
When I click save button on my addressMaintenanceForm I want this location object to be available as it is. Is there any other way beside setting it in session. Thanks for your reply. Imad
posted 14 years ago
Another solution would be:
Discontinue use of DynaAction form and write a form bean extending ActionForm.
put all fields needed to construct the Location object in the JSP as hidden fields (e.g. location.property1, location.property2, etc.)
In the getLocation() method, check to see if the location object is null. If it is null, instantiate it. Then, when Struts calls getLocation().setProperty1() the location object will be there.
Warning: The below statements consist of me getting on my soap box. Read on at your own risk
We've all read the J2EE best practice white papers that say "Don't put unnecessary data or a lot of data in your HTTPSession". While I agree with this in principle, I believe many of this have taken this to mean "Don't put anything in an HTTPSession, and go to whatever extraordinary lengths necessary to avoid using it."
The whole point of having an HTTPSession object is to allow us as developers to save bits of data that we might need between requests. As long as we use it judiciously and don't put the kitchen sink in the session, using it is quite often the best and simplest way of solving a problem.