• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

Action class execute method not getting called

 
Ranch Hand
Posts: 99
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello all,
I am trying to run a simple struts application.
When I am submitting the JSP,the action form validate method is called successfully but my action class execute method is never called.

The URL is displayed blank with the /item.do

Please help

Thanks,
Shriya
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Are you completely sure the execute method is not getting called? Have you put a System.out.println statement somewhere in the method to see if it gets printed?

In my experience, when you get a blank page with the correct URL showing, that means the action didn't return a forward. This could be a simple as misspelling the forward name. For example: mapping.findForward("sucess") instead of mapping.findForward("success");
 
Viidhya Kishore
Ranch Hand
Posts: 99
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for your response.

I have put System.out in the very first line of action class.
Code snippet:
JSP:
<%@ page language="java" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>

<html>
<head>
<title>Web JSP</title>
</head>
<body>
<html:errors/>
<html:form action="/submit.do">
Lastname <html:text property="lastname"/>
Address <html:textarea property="address"/>

Married <html:checkbox property="married"/>

<html:submit/>
</html:form>
</body>
</html>

Struts Config :
<action path="/submit"
type="web.WebAction"
name="webForm"
input="/web.jsp"
scope="request"
validate="true">
<forward name="success" path="/index.jsp"/>
<forward name="failure" path="/error.jsp"/>
</action>

Action class :
public ActionForward execute(ActionMapping mapping,HttpServletRequest request, ActionForm form,HttpServletResponse response){

System.out.println("enter action");
WebForm webform=(WebForm)form;
String lastname=webform.getLastname();
request.setAttribute("lastname",lastname.toUpperCase());
return(mapping.findForward("success"));
}
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Your execute method has the wrong signature. The required parameters are all there, but they are in the wrong order. Your execute method must have exactly the following signature:
 
Viidhya Kishore
Ranch Hand
Posts: 99
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thank you very much .I got my issue solved.Thanks once again
 
Ranch Hand
Posts: 191
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i am also facing the same problem, even though my execute method has correct signature. please find below the code for LoginAction class:



s.o.p. statement written in the constructor is getting called but s.o.p. written in the execute method is not getting called. please help me out.
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You already have one thread open for this; please use only one thread per question.
 
What are you doing in my house? Get 'em tiny ad!
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic