It's not a secret anymore!
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

Not include webapp context path

Mike Nason

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 that pointed to http://testmachine/site - and that is where problems began.
I notice that all links was like - 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 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 >pointed to>http://testmachine/site
2. How to have <s:form action="sendMail.action" method="get" theme="simple"> pointed to but not on ??

Wanna code??
David Newton

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

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
I agree. Here's the link:
subject: Not include webapp context path
It's not a secret anymore!