aspose file tools*
The moose likes Struts and the fly likes why my link have Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "why my link have "//" instead of "/"" Watch "why my link have "//" instead of "/"" New topic
Author

why my link have "//" instead of "/"

Davie Lin
Ranch Hand

Joined: Aug 05, 2007
Posts: 294
I am sorry, I am really frustrated, in my HelloPage.jsp

I have ">Register Here

and in my struts.xml



when I start the app, Tomcat console gives me namespace "//Pay_Roll"

why the extra / I really don't get it, what did I do wrong?

Please help
Nishan Patel
Ranch Hand

Joined: Sep 07, 2008
Posts: 686


Hi,

Please see just remove "/" from Pay_Roll.

Like : <package name="Pay_Roll" namespace="Pay_Roll/Action" extends="struts-default">



Thanks, Nishan Patel
SCJP 1.5, SCWCD 1.5, OCPJWSD Java Developer,My Blog
Davie Lin
Ranch Hand

Joined: Aug 05, 2007
Posts: 294
I tried that before, no luck. thanks for reading my post
Nishan Patel
Ranch Hand

Joined: Sep 07, 2008
Posts: 686



Hi,

Then can you please check your web.xml


it might looks like this..

<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>

Please make sure it.

Davie Lin
Ranch Hand

Joined: Aug 05, 2007
Posts: 294
Thanks for responding so quickly

here is what my web.xml looks like



Does that look correct? what should I change?
I thought because the link contain two "/" that's causing the HTTP 404 error
but even if I remove the extra "/" it still give me the Action not mapped to Register.action

I know that my struts.xml is in /WEB-INF/ and should be /WEB-INF/classes
but I can't figure out how I can change my build.xml so that when Ant builds War file to place struts.xml in the right directory.
The only thing I can think of to do is to redo the entire project since it's not a big project yet.

thanks again
Nishan Patel
Ranch Hand

Joined: Sep 07, 2008
Posts: 686



Hi

Why you write in your wel-come file with Package name it just shows simple like this

<welcome-file-list>
<welcome-file>/index.htm</welcome-file>
</welcome-file-list>
<welcome-file-list>
<welcome-file>/index.jsp</welcome-file>
</welcome-file-list>

Remove /Pay_Roll

And for your 404 error

<error-page>
<error-code>404</error-code>
<location>/index.htm</location>
</error-page>


Davie Lin
Ranch Hand

Joined: Aug 05, 2007
Posts: 294
really? but that's where the welcome file is located

if I remove "Pay_Roll" and just have

<welcome-file>/HelloPage.jsp<welcome-file>

well work?

sorry, haven't have time to try that since you reply so quickly

I never know the <error-page> tag
what does it do and where does it needs to be, my guess is web.xml

but I don't see how that solve the problem since Tomcat is having problem finding the action
that the request is asking

thanks

Nishan Patel
Ranch Hand

Joined: Sep 07, 2008
Posts: 686


Hi,

Forgot about your <welcome-file>/HelloPage.jsp<welcome-file> .

Just make one action "index" at your struts.xml like others action you have declared.

from this index action just include your /HelloPage.jsp on success result type like.

<welcome-file-list>
<welcome-file>/index.htm</welcome-file>
</welcome-file-list>


And if you still want to list your /HelloPage.jsp then put this jsp at your Webroot directory.



David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Your struts.xml is in WEB-INF? That won't work unless you configure S2 to look for it there.

It'd be better if you fix your environment to work right.
Davie Lin
Ranch Hand

Joined: Aug 05, 2007
Posts: 294
Thanks Mr. Newton
but I am new to Struts 2
when you say S2 you mean Struts 2 right

I am guessing my struts.xml is the problem why I am getting HTTP 404 Action not mapped correctly

should I redo the project (which is not too bad because it's not huge)
or rewrite the build.xml so struts.xml will be in /WEB-INF/classes?

I am using Eclipse but it won't show the /WEB-INF/classes on the left side,
how do I fix my environment? can you give me some directions?
what are my best options?

thanks for reading my problem, I really appreciated

David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

If you're using Eclipse put the struts.xml file in the src directory and it will deploy it to WEB-INF/classes.

If you're using Ant then copy it to the right spot in the war or when you deploy.

You can also configure Struts to look in a non-default location, but it's probably a better idea to keep it on the classpath.
Davie Lin
Ranch Hand

Joined: Aug 05, 2007
Posts: 294
Mr. Newton

When you say Using Ant and copy it to the right directory in <war>

my guess is you do the copy operation inside the <war></war>
Here is the the <war> part in my build.xml


would I say insert a <copy> somewhere in <war></war> I am not quite exactly sure how that's done
can you give me a hint?

I try doing that in <classes></classes> but it didn't work, struts.xml still in /WEB-INF

is there any other tag beside <copy> that I can use in Ant? that will move struts.xml instead of copy it

I haven't have time to try the things you suggest yet but I will give it a shot soon, I will put struts.xml in src directory this time
if that doesn't work than I will also try leaving struts.xml in ${src.dir} so that way it ends up in /WEB-INF/classes

Thank you so much for your input, I really appreciated
Davie Lin
Ranch Hand

Joined: Aug 05, 2007
Posts: 294
I follow Mr. Newton's suggestion and move the struts.xml in src folder
but it still not in the right directory, It's ok, I use <copy> before <war> to
relocate struts.xml into the /WEB-INF/classes directory.

so, than I am still having "//Pay_Roll" with the extra "/"

now I try to delete the extra "/" and it goes to the page I want
because my struts.xml is in the right place now

so I believe, maybe the problem is in my <welcome-file>
(not the web.xml, the entry in the <welcome-file> tag)
which is my HelloPage.jsp

I have



I think here is the problem with my <s:url> tag

can anyone tell me what I did wrong here?

thank you
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: why my link have "//" instead of "/"