• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to send object from jsp to controller

 
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I am using hidden fields to send my data from JSP back to Controller. I am using springs framework.

I am sending a map from controller to jsp, like return new ModelAndView (viewName,"model",aggregateModel). Now i want to send this Map from jsp back to controller. Using hidden fields, i am able to set only one attribute to one field.

Is there a way to set an entire object in jsp, so that i can retrieve it back in my controller.
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Java objects can't exist in a browser so once your JSP's output is drawn to the screen, you're limited to what you can put in HTML form fields.

Another option is to bind your map to session scope where it can be read by subsequent requests.

Also, if you create multiple html form field with the same name, they can be retrieved as an array with request.getParameterValues("field_name").
See:
http://java.sun.com/j2ee/1.4/docs/api/javax/servlet/ServletRequest.html#getParameterValues(java.lang.String)
 
reply
    Bookmark Topic Watch Topic
  • New Topic