aspose file tools*
The moose likes JSP and the fly likes How to get WebApplication name, not the DisplayName Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "How to get WebApplication name, not the DisplayName" Watch "How to get WebApplication name, not the DisplayName" New topic
Author

How to get WebApplication name, not the DisplayName

eric mcentee
Ranch Hand

Joined: May 02, 2001
Posts: 66
Hello, quick question... I've searched the forum and can't seem to find an answer.
I'm not sure if this is possible, but can you get the actual WebApplication name from a JSP using taglib's?
I know I can get a ServletContext from a PageContext, and then use getServletContextName(), but this returns the display name, and I need to get to the actual WebApp name.
The only other thing I can think is to use getRealPath(String pathName) off of ServletContext and parse the string that comes back. I don't want to do this because 1)It's nasty, 2) I don't want to have to construct a fake virtual path just to pass into this.
Thanks for the help....
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61426
    
  67

if by "WebApplication name" you mean the app context, you can get it off the request with getContextPath() (and strip off the slash if you prefer).
hth,
bear


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
eric mcentee
Ranch Hand

Joined: May 02, 2001
Posts: 66
Hmmmm..
So if I have the following directory structure..

I will be able to get to "MyWebApp" using that method?
Thanks for the reply, this is a dumb question, but its really got me confused.
[ September 05, 2003: Message edited by: eric mcentee ]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61426
    
  67

Yes, unless you explicitly mapped the context to another name. You could also just try it out and see if it gets you what you want.
hth,
bear
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: How to get WebApplication name, not the DisplayName