Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Passing Atrribute Object From Jsp To Action

 
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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
  • 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

    Bookmark Topic Watch Topic
  • New Topic