File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Spring and the fly likes passing an object from one controller to another Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "passing an object from one controller to another" Watch "passing an object from one controller to another" New topic

passing an object from one controller to another

joseph mv

Joined: Jun 01, 2011
Posts: 1
I have a user registration jsp page that asks the user to enter his personal information in text boxes and also upload his photo.
I have placed the personal information section in one form and the photo upload section in another form.
I am trying to submit the first form to Controller1 and the second form (which is multipart/form-data) to Controller2.
After setting the personal information in the entity bean in Controller1, I want to pass this object to Controller2 so that the photo (in bytes) can also be set in the entity bean.
Also, in Controller2 I have to submit the object into the database.

The challenge that I am facing is:

1) When I try to pass the entity bean object from Controller1 to Controller2, the showForm method of Controller2 is not getting called.

In Controller1, I forward the entity bean object using the following line of code:

return new ModelAndView("forward:photouploader.html","mydata",bd);

And in Controller2, I have written this code :

protected ModelAndView showForm (HttpServletRequest request,
HttpServletResponse response) {

//The object from Controller1 doesnt come here

Here photouploader.html refers to Controller2.
And bd is the object I want to pass to Controller2

Please note I am using Spring 2.5
I agree. Here's the link:
subject: passing an object from one controller to another
It's not a secret anymore!