• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

why i cannot get request object in Action class from jsp

 
Kaleeswaran Karuppusamy
Ranch Hand
Posts: 155
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i cannot get request object in action class in struts.i set arraylist value in request Object(request.setAttribute()),howerver i connot get request object in DispatchAction class using request.getAttribute(). please tell is there any other way to get ArrayList Object from jsp page to Action class excluding session Object.

 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can't pass data from a JSP to an action by using request.setAttribute in the JSP. The reason for this is that the when the JSP is rendered and the resultant HTML sent back to the browser, the request is then out of scope. When the Action is called, you have an entirely new instance of HTTPServletRequest, and the old one is no longer accessible.

If you want to pass data from the JSP to the Action, the best way to do so is by setting form input fields to some value. If you want to pass a value that is not displayed, use a hidden field (html:hidden tag).
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic