0

I've got a struts2 application running under a contextpath "/path" on my local tomcat without problems. When I deploy it on a webserver (using a proxy to redirect from "http://www.domain.com" to "myserver:8080/path/") Struts does all kinds of strange things.

First, it includes the context in -tags. That can be turned off by an attribute. But sadly, it also includes the path in the action attributes of my forms, so a login form points to "http://www.domain.com/path/login.action" instead of "http://www.domain.com/login.action" ...

Is there a possibility so somehow change the default context that is added here or turn this off for forms? (I'd like to keep the -tags, only way round seems to be to use default HTML forms.) Thanks in advance!

CoolBeans
  • 20,654
  • 10
  • 86
  • 101
Akku
  • 4,373
  • 4
  • 48
  • 67
  • I did some tests and I think you'll have to resort to using the default HTML form element and setting the action with the `` tag. The odd thing is that the WebWork docs (https://cwiki.apache.org/WW/form.html) show an includeContext param on the `` tag. This is the first time I've seen behaviour missing from Struts2 that's in WebWork. – Pat Jul 27 '10 at 13:54
  • Hey there! Thanks for your answer. Sadly, the action attribute of the doesn't take a . Only workaround seems to be not using the s:form tag - which I don't want to. – Akku Aug 02 '10 at 09:00
  • Using includeContext="false" also doesn't change anything. – Akku Aug 02 '10 at 09:01

2 Answers2

0

Though am answering very late to this question, but I reached this page recently when I was facing the same problem.

The application that I was working upon was appending the context-root viz. 'myContextRoot' to my url on localhost and it was working perfectly there. For eg., as mentioned above the action 'myAction' was becoming http://localhost:8050/myContextRoot/myAction.action But the moment I deployed it on a server, it stopped working, then after searching like hell, I found a solution for me. I am deploying an EAR file on glassfish and there we have a file application.xml. In application.xml I had a tag 'context-root' whose value was 'myContextRoot' which I changed to '/' and after that I got my url as on localhost and

Hope it may help :)

ankit
  • 1
  • 2
0

I found that others also had the problem, but the framework makers don't seem to think that this is an issue. My solutions:

  • use includeContext="false" in all s:url-tags
  • instead of the s:form tag, use a usual form, set the action to "actionname.action" and include a simple table with tablerows () for each field. You still can use s:textfield and such.
  • sadly HTTP sessions won't work anymore as they get set for the path "/path" (the ApplicationPath). This is due to the cookie that saves the JSESSIONID being set to /path. This means that your visitors will only get session variables stored when they're at http://www.domain.com/path/login.action and that those will be lost when they get redirected back to http://www.domain.com/interestingstuff.action ... my solution is a hack that requires setting the JSESSIONID cookie clientside via JavaScript as described here: Struts2: Session Problem (after reverse proxy)

Hope this helps someone ... if you find nicer solutions, please let me know. :-)

Community
  • 1
  • 1
Akku
  • 4,373
  • 4
  • 48
  • 67