File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes Newbie Question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Newbie Question" Watch "Newbie Question" New topic

Newbie Question

Sandeep Awasthi
Ranch Hand

Joined: Oct 23, 2003
Posts: 597
Hi All,

I am new to struts and I have come accross a problem.

I have one action class which extends DispatchAction and it used to display list of Emps or Depts depending on actionType parameter.

Now I have one more class DispatchAction Class which I use to either edit or add new Emp depending on value of actionType parameter.

After adding an employee, I want to forward it to ShowList action.

<!-- Default forward to "Welcome" action -->
<!-- Demonstrates using index.jsp to forward -->
<forward name="welcome" path="/"/>
<forward name="ShowList" path="/"/>

<action path="/ShowList"

<forward name="ShowEmpList" path="/pages/EmpList.jsp"/>
<forward name="ShowDeptList" path="/pages/DeptList.jsp"/>


<action path="/EmpEdit"

<forward name="success" path="/ShowList"/>

Obviously this will not work because after adding emp, actionType parameter will have value either addEmp or editEmp and showList action expects showEmpList or showDeptList.

Is there a way to set parameter actionType to some value(e.g. showEmpList in this case) in Action class,before I forward action to ShowList

Thanks alot in advance

Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
Try this in your action:

forward = mapping.findForward("ShowList");

Consultant, Sima Solutions
I agree. Here's the link:
subject: Newbie Question
It's not a secret anymore!