This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Struts and the fly likes Second call to Struts action Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Second call to Struts action " Watch "Second call to Struts action " New topic
Author

Second call to Struts action

Mark Brothers
Greenhorn

Joined: Apr 15, 2004
Posts: 14
On Page1.jsp, their is an Href link that calls the sendEmailAction. This action includes the look up of a piece of data in an arraylist via the index number passed from the Page1.jsp - it then forwards to Page2.jsp (where part of the email message body is entered by the user). This Page2.jsp then calls the same sendEmailAction - but the index parameter is now null (since it is not coming from the current page. My question is - how can I code this action to be able to continue to use it as it is now (called from Page1.jsp and from Page2.jsp) to be able to execute the exact same code (without losing parameters)? If this is not possible, what is the scenario I need to look at (2 separate actions, etc.) that will aloow me to accomplish the following functionality?

Snippet from action:
//get participation data
ArrayList partData = (ArrayList) session.getAttribute(JUVENILE_PARTICIPATION);

if (request.getParameter("indx") == null)
{
errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("system.error.general"));
l4jCategory.warn("Parameter 'indx' not found in the user request.");
return mapping.findForward(FAILURE_FORWARD);
}
int indx = Integer.parseInt(request.getParameter("indx"));
JuvenileParticipationData pData = (JuvenileParticipationData) partData.get(indx);
String sendTo = pData.getContactEmail();

// use test email or actual email
String email = OSCACfg.EMAIL_TEST?OSCACfg.EMAIL_TEST_ADDR:sendTo;

User sees list of items associated with a selected user on jsp Page1. User selects one of the items (this is where I get my index). Jsp Page2 is rendered with information from Page1 and a lookup in the action to get the specific informatino associated with the detail record the user selected. User types some content and hits a submit button to send email. Same action is then called to actually send the email and display a success/fail page, depending on outcome.

Thanks so much for any light that can be shed on this topic.
Mark Brothers
Greenhorn

Joined: Apr 15, 2004
Posts: 14
A nice hidden item on the jsp has solved my problem. Its good to have coworkers with vast amounts of experience and knowledge - Thanks to Cory!
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Second call to Struts action
 
Similar Threads
Problem getting session attributes
jsp page redirection
session problem in jsp
Struts 1.2.9 +text areas.
Problem with session