I’m trying to pass data between 2 Action classes. I’m currently doing this
In my first Action class
doExecute(){
request.setAttribute("Order_ID", 2);
// code to find forward to next Action class
}
In the following Action class
doExecute(){
Object id = request.getAttribute("Order_ID");
// code to process id
}
However, the getAttribute() method always returns null. How can I property pass data between 2 action forms that follow each other?
Thanks in advance
There are number of ways , you can do this.
Method 1:
Set the attribute in session and then get the value back and then remove it from session.
then return it back.
Method 2:
Pass the value in url and then get it back from other action but here need to keep in mind that your request doesn’t loss.
For more please refer below link.
http://www.apl.jhu.edu/~hall/java/Servlet-Tutorial/Servlet-Tutorial-Session-Tracking.html