File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Win a copy of
REST with Spring (video course)
this week in the
Get Context Root From Servlet Code
Joined: Jun 02, 2004
Jun 02, 2004 00:32:00
code I try to query the (deployed) context root of my
web application. By context root I mean that usually a http request
looks like this:
I tried to use ServletContext.getServletContextName() but it does not
servers I am using.
What I would do is to limit my web app to only be deployed under
certain context root. Otherwise my servlet will serve a http request
Is there a way to do this?
Joined: Oct 12, 2000
Jun 02, 2004 04:34:00
check out the javadocs for HttpServletRequest, and in specific the getRequestURL method.
But of course you've done that already because you know that the API docs are your friend?
Joined: Jan 22, 2004
Jun 02, 2004 09:47:00
ServletContext.getServletContextName() gets the display-name of that context. It may not be the real context path.
Use Request.getContextPath() method
I agree. Here's the link:
subject: Get Context Root From Servlet Code
Context Root be only /
tomcat 6 - how to define context root name diff than WAR file name
Need ear installation help
Can't write Context element properly
Can a servlet know the "context root" of the application ?
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2015