Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Struts2 struck with a issue of 404

 
RaviNada Kiran
Ranch Hand
Posts: 528
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
MY index.jsp page




MY struts.xml file:



I am getting 404 eroor (I have my HelloStruts2World class in my hello package also)

type Status report

message /HelloStruts2World/HelloStruts2World

description The requested resource (/HelloStruts2World/HelloStruts2World) is not available.


I am able to display my index page , after submit i get the above one.
Please tell me is there anything i need to change anywhere.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you accessing the JSP page directly to get to the form? Have you verified the emitted HTML is correct? Can you access the action directly (i.e., not via form submission)?
 
RaviNada Kiran
Ranch Hand
Posts: 528
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using NetBeans as IDE . When i click Run on to the IDE:

This is the URL shown "http://localhost:8088/HelloStruts2World/" on the browser.

And i get the JSP page displayed

and also when i type http://localhost:8088/HelloStruts2World/index.jsp

the page will be shown.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you verified the emitted HTML is correct?

Accessing the JSP page directly will most likely *not* work; the S2 tags expect there to be a value stack available--I'm not sure that it would generate the appropriate HTML (but it might). It's generally best not to mix JSP/action access in a single application (and there's almost never a reason to anyway).
 
RaviNada Kiran
Ranch Hand
Posts: 528
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
David Newton wrote: Can you access the action directly (i.e., not via form submission)?


How can i check this ??



 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
...

Type in the URL of the action.
 
RaviNada Kiran
Ranch Hand
Posts: 528
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
David Newton wrote:...

Type in the URL of the action.


I tried that but same thing 404.

This is my whole index.jsp page:

 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So...

- you're deploying to the "/HelloStruts2World" context
- /HelloStruts2World/index.jsp *does* show the JSP.
- /HelloStruts2World/HelloStruts2World.action does *not* work?

Are there any errors on startup? Do you have devMode turned on and logging turned up? What libraries are you deploying?

You could also try setting your package's "namespace" attribute to "/" just to eliminate another possible source of error.
 
RaviNada Kiran
Ranch Hand
Posts: 528
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I already tried putting package names with

1. .

2. /

3. left it balnk also



 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The other questions I asked were important too. Might as well include your web.xml too to make sure the filter is set up correctly.
 
RaviNada Kiran
Ranch Hand
Posts: 528
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I extracted the war file created and checking everything . But for me everything seems okay.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I wrote: Are there any errors on startup? Do you have devMode turned on and logging turned up? What libraries are you deploying?

Which version of S2 are you using?
 
RaviNada Kiran
Ranch Hand
Posts: 528
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
David Newton wrote:
I wrote: Are there any errors on startup? Do you have devMode turned on and logging turned up? What libraries are you deploying?


everthing is successful shown on IDE console , just checked server logs
I just checked everything on to server logs simply displaying




Which version of S2 are you using?


struts-2.0.14

I am using only 5 jar files commons-logging-1.0.4 , freemarker-2.3.8 , ognl-2.6.11 , struts2-core-2.0.14 , xwork-2.0.7
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I wrote:Are there any errors on startup? Do you have devMode turned on and logging turned up?
 
RaviNada Kiran
Ranch Hand
Posts: 528
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I just include <constant name="struts.devMode" value="true" /> this is struts.xml .But i don't know how this works .


Again nothing on server side logs.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You should probably configure logging to include debug information from Struts and XWork; it's odd to see *nothing* on startup.
 
Sam Tsang
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have the same issues many times when I first used struts 2. You need to check your struts.xml, make sure everything in this file is correct, for instance, action names, action classes, global results, interceptors, maybe you typed some action strings in your action class but forgot to refer them in struts.xml.
You can remove some parts in struts.xml to test which part goes wrong.
 
Davie Lin
Ranch Hand
Posts: 294
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
where are your struts.xml located at?
is it in /WEB-INF/classes
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic