aspose file tools*
The moose likes Struts and the fly likes Struts2: Simple example-Action not getting invoked; status 404 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts2: Simple example-Action not getting invoked; status 404" Watch "Struts2: Simple example-Action not getting invoked; status 404" New topic
Author

Struts2: Simple example-Action not getting invoked; status 404

Baz Matt
Greenhorn

Joined: Feb 26, 2013
Posts: 12
I`m new to Struts2 and trying to get a simple example up and running. Can't seem to figure out where I`m going wrong.
I`m just trying to print out a hello message with the value input in the index.jsp. Once the value is submitted in the Index.jsp, I keep getting
a HTTP 404 error saying that 'The requested resource is not available'. Appreciate answers to point me in the right direction.


Following are the files used:

index.jsp ----->WebContent
HelloWorld.jsp ----->WebContent

struts.xml ----->WebContent/WEB-INF/classes
web.xml ----->WebContent/WEB-INF
HelloWorldAction.java

Index.jsp




struts.xml




web.xml

Ankit Dan
Ranch Hand

Joined: Aug 31, 2012
Posts: 47

woah woah!!
to get struts running you have to use struts tags, you have used HTML tags

here is what it ll look like after you ll use struts tag




hope this helps

Ankit
Baz Matt
Greenhorn

Joined: Feb 26, 2013
Posts: 12
I had already tried using the struts tags as you mentioned earlier, but resorted to using the html tag as I was getting the following exception.
When using html tags, I was able to view the index.jsp page atleast, the problem occurred only when submitting the page.
Any ideas?

Saif Asif
Ranch Hand

Joined: Aug 11, 2011
Posts: 440

Hello Baz Matt ,

First I want you to check 2 things,

1) Are you trying to access the JSP page directly with the struts tags ? Sometimes this error arises due to directly accessing the JSP and not letting the Dispatcher to initialize the request processing cycle and create needed value stack. In this case , you will have to write an action class that you will initialy hit which will then render the JSP page for you.

2) My second guess is the filterDispatcher. This may be the cause of the issue and I am just sharing my experience because I spent countless hours to determine the solution to this problem when I started learning struts. In the web.xml you have defined the filterDispatcher as org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter , try changing this to the old dispatcher org.apache.struts2.dispatcher.FilterDispatcher. Again , this step is just a wild guess I am taking , it may or may not solve your problem.

3) what URL do you type to invoke your action ?


Muhammad Saif Asif Mirza
OCJA(5/6) OCJP(6) OCJWCD(6)
 
Consider Paul's rocket mass heater.
 
subject: Struts2: Simple example-Action not getting invoked; status 404