• 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 ...
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Please review code for LookupDisptach using Image Buttons

Ranch Hand
Posts: 131
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a jsp with 2 image buttons, and i needed to
forward the request to different jsp depending upon
the image button clicked by the user, and I want to do
it without using javascript ( I was using javascript
along with DispatchAction class)
Here is what I have done,
I wrote a new class called TestLookupDispatchAction
which extend DispatchAction class, override execute
method and has one abrstact method called
I am pasting the code of my
TestLookupDispatchAction and the class which extends
this TestLookupDispatchAction class and my jsp
definitation of code,
Can people please comment on it
public abstract class TestLookupDispatchAction extends
public ActionForward execute (
ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws Exception
String methodName = getMethodName(request ,
return dispatchMethod (mapping, form,
request, response, methodName);
protected abstract String getMethodName
(HttpServletRequest request, ActionMapping mapping );
/** class that extends this class**/
public class TestImageButton extends
protected String
request, ActionMapping mapping)
Enumeration enu = request.getParameterNames
String att="";
while(enu.hasMoreElements ())
att = (String)enu.nextElement ();
System.out.println ("parameter name: " +
att + "... value: " + request.getParameter (att));
if(att.equals ("add.x"))
return "add";
else if(att.equals ("change.x"))
return "change";
else if(att.equals ("back.x"))
return "back";

return "";
public ActionForward add (ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException
My jsp definiation
I am using normal html tag because i want to use the
mouse over effect, which is not possible to get using
struts taglib
<html:form action="pages/TestImageButton" >
<input type="image" src="<bean:message
key="button.addoff"/>" name="add"
on Mouse Over="MM_swapImage('add','','<bean:message
on Mouse Out="MM_swapImgRestore()"/>
<input type="image" src="<bean:message
key="button.changeoff"/>" name="change"
on Mouse Over="MM_swapImage('change','','<bean:message
on Mouse Out="MM_swapImgRestore()"/>
    Bookmark Topic Watch Topic
  • New Topic