A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
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
, 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
Did you see how Paul
cut 87% off of his electric heat bill with 82 watts of micro heaters
subject: Get Context Root From Servlet Code
Can't write Context element properly
Need ear installation help
Can a servlet know the "context root" of the application ?
Context Root be only /
tomcat 6 - how to define context root name diff than WAR file name
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2013