Re: ServletContext.getContextPath() ?
Endre Stølsvik <[email protected]> Mon, 19 Jul 2004 15:19:39 +0200 (CEST)
| Newsgroups | gmane.comp.java.advanced-servlets |
|---|---|
| Message-ID | <Pine.LNX.4.44.0407191459470.374-100000@excalibur.intra.coretrek.com> |
On 19 Jul 2004, Nic Ferrier wrote: | =?iso-8859-1?Q?Endre_St=F8lsvik?= <[email protected]> writes: | | > I must be missing something.. | > | > Where can I find HttpServletRequest.getContextPath()-like information, | > when only having the ServletContext? | > | > See, when I start up the web application, I'd like to check for some | > extra config-information based on what the web application is named. | > | > In ServletContext's JavaDoc, it says: | > " There is one context per "web application" per Java Virtual Machine. | > (A "web application" is a collection of servlets and content installed | > under a specific subset of the server's URL namespace such as /catalog and | > possibly installed via a .war file.) " | > | > But I -can't- get to this information (the "/catalog" part) w/o having a | > request to work from? I'm just wondering if I have lost half of my brain | > this weekend, or if something else is missing.. | > | > (I guess I in many circumstances could do some dirty trix with | > context.getRealPath("foo") og getResource("foo"), and then parsing the | > result for the context's name, but HEY this is really really bad, and not | > what you'd want.) | | | It's not possible for a webapp to know about where it is mapped until | a request comes in. | | It's stupid I know... I campaigned for some time to have that changed | but there was a belief that apps wouldn't be portable if this sort of | information was knowable. Eh, why would that make it less portable, said the belief? I mean, it is -defined- that "A webapplication is [..] installed under a specific subset of the server's URL namespace". Well, then, WHAT subset is that, please?! I mean, the DOM idea is all well, but in the meantime (that won't happen anytime soon, we all guess/know! ;), the information that the Servlet-spec obviously is built around should be made available to the developers! "-What am I called-", please? I mean, the information is available -directly- with a method in the Request object, so what's the deal? Oh well.. You still in the servlet-gang, Nic? Count one more developer's voice in on your voting for at least this one method next round! ;) Endre ------------------------ Yahoo! Groups Sponsor --------------------~--> Make a clean sweep of pop-up ads. Yahoo! Companion Toolbar. Now with Pop-Up Blocker. Get it for free! http://us.click.yahoo.com/L5YrjA/eSIIAA/yQLSAA/saFolB/TM --------------------------------------------------------------------~-> Before posting a question, try to find your answer here: <http://www.egroups.com/links/advanced-servlets> Announcements should go to: [email protected] To Post a message, send it to: [email protected] To Unsubscribe, send a blank message to: [email protected] Yahoo! Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/advanced-servlets/ <*> To unsubscribe from this group, send an email to: [email protected] <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/