File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes Dispatch VS LookupDispatch 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 "Dispatch VS LookupDispatch" Watch "Dispatch VS LookupDispatch" New topic

Dispatch VS LookupDispatch

sudhakar Tadepalli
Ranch Hand

Joined: Dec 27, 2001
Posts: 130
I have an Action extended to DsipatchAction with edit,delete methods.

My jsp form action = ""

<td><html:submit property="method" value="edit" />
<td><html:submit property="method" value="delete" />

Struts config file is :

<action path="/edit" type=""
name="dataForm" scope="session" parameter="method" validate="true" input="page.lifeA">
<forward name="edit" path="page.edit" />

<action path="/delete" type=""
name="dataForm" scope="session" parameter="method">
<forward name="success" path="page.success" />

Edit calling th action and then jsp. But when i submit delete action it is calling action and exceuting delete method but it is trying to send to edit page again instead success page. Reason my jsp form action ="/".

Ok now I thought of using LookUpDispatchAction class.

I extended action to LookupDispatchAction then implimented

protected Map getKeyMethodMap() {
Map map = new HashMap();
map.put("button.edit", "edit");
map.put("button.delete", "delete");
return map;

In JSP i chaged to :

<td><html:submit><bean:message key="button.edit"/></html:submit>
<td><html:submit><bean:message key="button.delete"/></html:submit>

I also changed parameter name from "method" to "submit" in struts config file

<action path="/edit" type=""
name="dataForm" scope="session" parameter="submit" validate="true" input="page.lifeA">
<forward name="edit" path="page.edit" />

<action path="/delete" type=""
name="dataForm" scope="session" parameter="submit">
<forward name="success" path="page.success" />

Now when i click edit I am getting the follwing error. Can some one point me?.

the example is using

protected Map getKeyMethodMap(ActionMapping mapping,
ActionForm form,
HttpServletRequest request) {} with parameters but LookupDisptach action has method without signature. Not sure wich one is lates and to use.

[Servlet Error]-[Request[/edit] does not contain handler parameter named submit]: javax.servlet.ServletException: Request[/edit] does not contain handler parameter named method
at java.lang.Throwable.<init>(
at java.lang.Throwable.<init>(
at javax.servlet.ServletException.<init>(
at org.apache.struts.actions.LookupDispatchAction.execute(

sudhakar Tadepalli
Ranch Hand

Joined: Dec 27, 2001
Posts: 130
The error was gone after I did the change in jsp and config files. I am using paramater="method" in struts config and in jsp

<td><html:submit property="method"><bean:message key="button.edit"/></html:submit>

<td><html:submit property="method"><bean:message key="button.delete"/></html:submit>

I explisitly specified property="method". I red that if i use parameter="submit" struts submit tag has default name as submit. But some how it does not work.

But i stil have problem with when i press delete button , delete method was executed but it is trying to redirect to edit.jsp instead of success page as my jsp from action=""
I agree. Here's the link:
subject: Dispatch VS LookupDispatch
Similar Threads
Using DispatchAction ,error whe nusing request scope
Problem compiling LookupDispatchAction
how to handle mutiple buttons
LookupDispatchAction with link, Please Help Me!!!