File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Action going nowhere

 
AnilPrakash Raju
Ranch Hand
Posts: 137
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have set a small struts application

I cannot figure where my actionmapping is pointing

The struts-config.xml is:

<struts-config>
<data-sources/>
<form-beans>
<form-bean name="GetNameForm" type="sample.GetNameForm"/>
</form-beans>
<global-exceptions/>
<global-forwards>
<forward name="getName" path="inputname.jsp"/>
</global-forwards>
<action-mappings>
<action name="GetNameForm" path="/greeting" scope="request" type="sample.GreetingAction">
<forward name="sayHello" path="greeting.jsp"/>
</action>
</action-mappings>
<controller/>
</struts-config>

The setup i got is:
Apache Software Foundation\Tomcat 5.5\webapps\StrutsHello

and under StrutsHello

WEB-INF
classes
lib
pages/
and under pages i got
index.jsp
inputname.jsp
greeting.jsp


I got it working from index.jsp(which just has a logic redirect forward) to the inputname.jsp
and when i press the submit button is seems to go to the greeting.do and does nothing.

(ie it gets to http://localhost:8080/StrutsHello/pages/inputname.jsp then pressing submit button with html:form action="/greeting.do"

it goes to : http://localhost:8080/StrutsHello/greeting.do and does nothing.

Any suggestions to what i am doing wrong?

Thanks

Anil
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Make sure that at the end of the execute() method of GreetingAction you have the statement:

return mapping.findForward("sayHello");

where mapping is the variable name for the ActoinMapping object passed in as a parameter to the execute method.
 
AnilPrakash Raju
Ranch Hand
Posts: 137
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Merrill,

I do have return mapping.findForward("sayHello") in the execute() method.

I was more concerned whether i placed the everything in the right structure.

Anil
 
sai prasanna
Ranch Hand
Posts: 167
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try with this
In the forward attribute check the path attribute starts with forward slash(/) for <global-forwards> as well as <action> forwards

<forward name="getName" path="/inputname.jsp"/>
 
AnilPrakash Raju
Ranch Hand
Posts: 137
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Sai,

Thanks for your suggestion.
I tried it but the same issue exist.
it just hangs on
http://localhost:8080/StrutsHello/greeting.do

Thanks

Anil
 
sai prasanna
Ranch Hand
Posts: 167
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
try by removing .do in form action attribute
html:form action="/greeting"
 
AnilPrakash Raju
Ranch Hand
Posts: 137
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Sai,

Tried your suggestion. It did not change anything. got the same issue.

Anil
 
sai prasanna
Ranch Hand
Posts: 167
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In the forward path attribute you try with pages/greeting.jsp or /pages/greeting.jsp
 
Sachin Kediyal
Greenhorn
Posts: 9
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Anil,
Replace your action mapping with this in struts-config.xml
<action path="/greeting" type="sample.GreetingAction" name="GetNameForm" scope="request" input="/pages/inputname.jsp" >
<forward name="sayHello" path="/pages/greeting.jsp"/>
</action>
The problem is the request is being passed to your GreetingAction Servlet.Your GreetingAction Servlet knows to dispatch
the request to "sayHello" to generate the response but it is not able to locate greeting.jsp since you had not mentioned the complete virtual path of greeting.jsp correctly.You have mentioned only (/greeting.jsp).
In the inputname.jsp your action tag should be like this
<html:action name="/greeting">
 
AnilPrakash Raju
Ranch Hand
Posts: 137
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks guys,

I stuffed in up in the Action

Made some changes to the Action but forgot to take the complied classes from eclipse to the tomcat directory.

Thanks



Anil
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic