• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to send object from jsp to controller  RSS feed

 
badri nath
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • 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.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • 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)
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!