wood burning stoves 2.0*
The moose likes Struts and the fly likes Getting 404 when trying to submit my form Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Getting 404 when trying to submit my form" Watch "Getting 404 when trying to submit my form" New topic
Author

Getting 404 when trying to submit my form

Dave Alvarado
Ranch Hand

Joined: Jul 02, 2008
Posts: 436
Hi, I'm using Struts 2. I have this on my JSP page ...

<html:form action="pcFlow" method="POST">

and I have this in my struts-config.xml file

<action-mappings>

<action path="/pcFlow"
type="com.myco.regui.struts.accounts.AccountsAction"
scope="request"
name="REAccountLookUpBean"
validate="true"
input="pcAccountLookupPage">
</action>

<global-forwards>
<forward name="pcAccountLookupPage" path="/jsp/pcAccountLookup.jsp" />

Yet when I submit my form, I'm getting a 404 error, telling me the URL http://localhost:7005/re/pcFlow.do cannot be found. What do I need to adjust/add in the above to make everything sync up?

Thanks, - Dave
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

I might be remembering this completely wrong, but I thought the "input" attribute had to be an action, JSP, tile, etc. rather than a forward--there was a way to configure this via the controller's "inputForward" attribute (see here).

I'm not too sure about this though. A quick way to sanity-check this would be to try using the JSP name directly. If it works, I might actually be right. If it's still broken, then it's something else still.
Dave Alvarado
Ranch Hand

Joined: Jul 02, 2008
Posts: 436
Per the suggestion, I changed my action to use the JSP submitting to the form

<action path="/pcFlow"
type="com.myco.regui.struts.accounts.AccountsAction"
scope="request"
name="REAccountLookUpBean"
validate="true"
input="/jsp/pcAccountLookup.jsp">
</action>

but I still get a 404 when the form submits to http://localhost:7005/re/pcFlow.do. Any other ideas are greatly appreciated, - Dave
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

I'd first look to make sure my app context ("re") is correct, then that the JSP page actually exists.

(Best practices, by the way, generally put JSPs under /WEB-INF, to disallow direct access from the browser. That's not related to this, though :)
Dave Alvarado
Ranch Hand

Joined: Jul 02, 2008
Posts: 436
I have verified that hte context path is correct. I can view this page

http://localhost:7005/re/jsp/pcAccountLookup.jsp

from which I'm submitting the form. Unfortunately I still get the 404 (http://localhost:7005/re/pcFlow.do). I even changed the action directive to include the context path ...

<action path="/pcFlow"
type="com.myco.regui.struts.accounts.AccountsAction"
scope="request"
name="REAccountLookUpBean"
validate="true"
input="/re/jsp/pcAccountLookup.jsp">
</action>

What next? - Dave
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

No clue. I'd turn up logging and see if there's anything in the console.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Getting 404 when trying to submit my form
 
Similar Threads
Struts validation problem..
Cannot find Bean under name..
Can't get error messages to display
How to tell where I came from?
Action not getting invoked in struts 2