0

I am currently running a Java web application on Tomcat 6, and have set up a virtual host in Apache HTTP Server to forward requests to the Tomcat. The context paths are therefore different. When the web app is accessed at

http://server:8080/WebApp

the context path is '/WebApp' and the context is retrieved. When accessing the same JSP via the proxy at

http://webapp/

the context path is '' and application.getContext() returns null.

Is there any configuration I might have missed when setting up the virtual host, or is this a problem with the application code?

0

1 Answer 1

3

There's no point in calling

application.getContext(application.getContextPath())

The getContext method is for getting a reference to the ServletContext for a different web application (and the container is allowed by the spec to return null if the current app does not have permission to access other contexts - this is the default in Tomcat unless you've specified crossContext="true" in the context configuration file).

You already have a reference to the ServletContext for the current webapp - in the application variable.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.