artemb
artemb

Reputation: 9371

Spring MVC application context path

My Spring MVC application is runnning on a Tomcat behind an Apache 2 acting as a proxy. I access my app directly in tomcat via an url like http://localhost:8080/myapp. I access my app via proxy with an url like http://localhost/tomcat/myapp.

The second url makes my app behave incorrectly, because it supposes it lives in /myapp context path, but via the proxy it should live in /tomcat/myapp.

Is there a variable in Spring or Servlet API, that holds /tomcat/myapp if I am accessing it via the proxy, and /myapp if I am accessing it directly?

Thanx

Upvotes: 3

Views: 5248

Answers (3)

Jesse
Jesse

Reputation: 11

Just stumbled upon this post while searching for the config setting for tomcat. There is a much easier way to configure tomcat to handle the exact situation you are experiencing. See:

http://tomcat.apache.org/tomcat-5.5-doc/proxy-howto.html

Simple configure a connector for the proxy in tomcat, and the servlet/struts context path issues will resolve.

-edit: Obviously I didn't read #2 comment...

Upvotes: 0

Adeel Ansari
Adeel Ansari

Reputation: 39887

I think you need to enable proxy support then. This link might help you or give a little hint in this regards.

Upvotes: 2

Faisal Feroz
Faisal Feroz

Reputation: 12785

I mean when I redirect to "/index.jsp" it actually redirects to "http://localhost/myapp/index.jsp" instead of "http://localhost/tomcat/myapp/index.jsp"

Redirect to index.jsp instead of /index.jsp

When you redirect to /index.jsp this acts as an absolute url and it gets redirected to myapp/index.jsp. index.jsp is a relative url and will redirect to tomcat/myapp/index.jsp

Upvotes: -1

Related Questions