Reputation: 351
I am trying to find the application root path with the following code on my local machine(Deployed in tomcat 6) .
${pageContext.servletContext.contextPath}
At local system it return "/ProjectName" eg:- "/Hello"
.
But when i put the same code in a remote server where my application is deployed in production mode it returns nothing there.
Please help me to get the application root path in production mode.thnks
Local URL is lenovo:7777/BharatWellness/showallpartners.do
and production one is bharatwellness.com/showallpartners.do
Upvotes: 0
Views: 813
Reputation: 873
Please see the DNS mapping for your production URL and check in server.xml file that to which directory in webapps the DNS is pointing to.
on other hand as you ask- you just need to call a servlet from jsp then why you needed to provide the context path, just specify the URL pattern defined in web.xml for that Servlet and that should work for you.
cheers
Upvotes: 4
Reputation: 149185
It looks like you are experimenting the root context path.
When you deploy a web application on a servlet container, it normally has a context path, and the full URL is :
scheme://host.domain/contextPath/url_inside_app
(where scheme is http
or https
)
But there is a special root context, (in tomcat it is ROOT
) that allows the web application to have an empty servlet context path. In that case the full URL is :
scheme://host.domain/url_inside_app
and Request.getContextPath()
or ${pageContext.servletContext.contextPath}
both return an empty string.
But it is fine, because when you construct your URL with
${pageContext.servletContext.contextPath}{$localpart}
it works.
[ Reference : HttpServletRequest.getContextPath()
javadoc : For servlets in the default (root) context, this method returns "" ]
Upvotes: 1