Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Baz Matt
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 47
Eclipse IDE Java MyEclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 440
Eclipse IDE Hibernate Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic