File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes Not include webapp context path Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Not include webapp context path" Watch "Not include webapp context path" New topic
Author

Not include webapp context path

Mike Nason
Greenhorn

Joined: Apr 19, 2006
Posts: 20
I have a problem with a site on struts2.
First I developed the site on http://localhost:8080/site
Then QA team deployed it to http://testmachine/site - all worked ok.
Then QA created http://sub.anotherdomain.com that pointed to http://testmachine/site - and that is where problems began.
I notice that all links was like http://sub.anotherdomain.com/site/some.action - it means that the real path link was pointing to was http://testmachine/site/site/some.action which was wrong.
The struts tag included the webapp context path (/site) which was the place the site actually deployed.

I found the way to work only on http://sub.anotherdomain.com/ or on http://testmachine/ (root context) with same way. I changed the includeContext="false" on all s:url tags. But that is not working with s:form that is still includes context information in action="sendMail.action".

1. How to have my site working both on http://testmachine/site and http://sub.anotherdomain.com/ >pointed to>http://testmachine/site
or
2. How to have <s:form action="sendMail.action" method="get" theme="simple"> pointed to http://sub.anotherdomain.com/sendMail.action but not on http://sub.anotherdomain.com/site/sendMail.action ??

Wanna code??
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

The form tag will include the application context, whether it's an empty string or an actual context--I'm not sure what problem you're actually having. Maybe the problem is that you're including the ".action" in the form tag, which is neither necessary, nor a good idea.
Peter DiCrescenzo
Greenhorn

Joined: Apr 16, 2010
Posts: 10
Hello again David - I believe I'm having the same problem that Mike Nason did.

Briefly stated, I'm trying to use a Struts2 form tag in an application which is deployed in an app in a WebLogic container, which is "front-ended" by a high-performance web server.

The server drives mapped URL requests back to my app using some re-writing rules -- so even though I've deployed my app with the context of MyApp, it brokers requests to a "jsp" folder at the root of the domain back to the application for handling.

The problem comes in when I use the <s:form> tag to set up a form pointing back to an action. I need the output of:



to be:



Instead of:



I see how having the Struts2 <s:form /> tag automatically prepend the context path would be useful, but like Mike Nason, I'm trying to find a way to prevent it. Is there an attribute in the tag that I'm misunderstanding, or a struts.xml value I need to enable?

Peter DiCrescenzo
peter.dicrescenzo@gartner.com
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Not include webapp context path
 
Similar Threads
How to set default "Context Root" for all urls in the webapp?
remove name and OnSubmit in s:form tag
Jsp is not displaying in Struts2
Creating dynamic titles
Struts2 newbee - Problem when using form tag