• 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

Passing Atrribute Object From Jsp To Action

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

I have a situation like that;

In a page, lets say product.jsp, I fill the textBoxes and I submitted the form and I am redirected to the action mapping of this jsp
In this actionMethod I get the ,lets say productForm, and then I called the function "request.setAttribute("productForm",productForm);
Then I am redirected to the "consumer.jsp". In consumer.jsp page, I can reach the attribute of productForm.

In the consumer.jsp, when I clicked a button I will be forwarded to the another action mapping, namely another actionMethod.

And I want to reach the productForm in this actionMethod.
How can I submit this form bean from jsp to method?

Thanks
 
Ranch Hand
Posts: 93
Python Redhat Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You confused me
Please be some more specific. Show us some code.
 
pamir sonmez
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
first jsp:

<html:form action="product">
<html:hidden property="method" value="add" />
<html:submit>Add</html:submit>
/>

From this jsp, when I clicked submit I am forwarded to the action method;

public ActionForward add(...) {
.....
productForm = (ProductForm) actionForm;
request.setAttribute("productForm",productForm);
return mapping.findforward(..);
}

Then I am directed to another jsp;
In this jsp I can reach the object like
<%
ProductForm = request.getAttribute("productForm");
%>

And In this page I hava a submit button again;
<html:form action="product">
<html:hidden property="method" value="check" />
<html:submit>Add</html:submit>
/>

So when I clicked the button I am forwarded to the action method;
public ActionForward check(...) {

/*
In this method I want to reach product object like
productForm = request.getAttribute("productForm");
*/
}
 
Karthik Jayachandran
Ranch Hand
Posts: 93
Python Redhat Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

In a page, lets say product.jsp, I fill the textBoxes and I submitted the form and I am redirected to the action mapping of this jsp .....

Then I am redirected to the "consumer.jsp". In consumer.jsp page, I can reach the attribute of productForm.



Not sure whether you are 'redirecting' to customer.jsp. If you have set redirect="true" in the action mapping, then this will clear any object in request scope and creates new request. So, instead you can have that form object in session scope.

/*
In this method I want to reach product object like
productForm = request.getAttribute("productForm");
*/



Also do a casting of your ActionForm object. After customer.jsp submit, in the action get the object as

 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic