aspose file tools*
The moose likes Struts and the fly likes Action going nowhere Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Action going nowhere" Watch "Action going nowhere" New topic
Author

Action going nowhere

AnilPrakash Raju
Ranch Hand

Joined: Jul 26, 2004
Posts: 137
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

Joined: Feb 15, 2005
Posts: 4864
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.


Merrill
Consultant, Sima Solutions
AnilPrakash Raju
Ranch Hand

Joined: Jul 26, 2004
Posts: 137
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

Joined: May 02, 2005
Posts: 167
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

Joined: Jul 26, 2004
Posts: 137
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

Joined: May 02, 2005
Posts: 167
try by removing .do in form action attribute
html:form action="/greeting"
AnilPrakash Raju
Ranch Hand

Joined: Jul 26, 2004
Posts: 137
Thanks Sai,

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

Anil
sai prasanna
Ranch Hand

Joined: May 02, 2005
Posts: 167
In the forward path attribute you try with pages/greeting.jsp or /pages/greeting.jsp
Sachin Kediyal
Greenhorn

Joined: May 11, 2006
Posts: 9
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

Joined: Jul 26, 2004
Posts: 137
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Action going nowhere