Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link
  • 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 ...
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
  • Piet Souris
  • Himai Minh

struts 1.* sedding forms

Ranch Hand
Posts: 111
Eclipse IDE Firefox Browser Debian
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I need to pass a form and a vector of object to an Action

I have tried the following

Vector v =(Vector)request.getAttribute("VECTOR");
request.setAttribute("VECTOR", v);

<html:form action ="/">


The vector is arives empy at the action.
I also have tried to include the vector as an attribute of the form but I get an exception ();

Is there any way to pass the vector and the form to an action without using a sesion atributte for the vector?
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you put a vector in request scope, it will be available to the JSP you're forwarding to, but it will not be available to the Action class that's called when the JSP's form is submitted. The reason for this is that request scope only lasts for the duration of a single request. Once the JSP has been rendered into HTML and sent back to the browser, anything placed in request scope is now out of scope. When the user presses the submit button, that starts a new request.

If you want to keep a vector or some implementation of in your ActionForm and update the elements based on what the user enters, you may want to consider using "mapped properties" as explained in this link. Even here, though, you will have to implement some sort of "lazy initialization" in your ActionForm if it's in request scope, because the vector or map will have to be re-instantiated and re-populated each time a request is submitted.
You’ll find me in my office. I’ll probably be drinking. And reading this tiny ad.
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
    Bookmark Topic Watch Topic
  • New Topic