Is it possible to programmatically get the name of the web application from jsp/servlet?
I have a utility class that creates a url, I want to be able to dynamicaly get the name of the web app to pass into the class. For example:
if I want to create a url for the login page.
util.getUrl("Login");
this will return the url of the login page, but if I am inside of a web application I want to be able to append the name to get
mywebapp/Login.jsp
Thanks
-
Getting web app name (6 messages)
- Posted by: Steve Chernyak
- Posted on: April 30 2001 18:51 EDT
Threaded Messages (6)
- Getting web app name by Jason McKerr on May 01 2001 00:35 EDT
- Getting web app name by Jason McKerr on May 01 2001 00:36 EDT
- Getting web app name by Geoffrey Wiseman on May 01 2001 07:07 EDT
- Getting web app name by Bhargav Srirangam on May 01 2001 10:36 EDT
- Getting web app name by Bhargav Srirangam on May 01 2001 10:40 EDT
- Getting web app name by Steve Chernyak on May 01 2001 12:26 EDT
-
Getting web app name[ Go to top ]
- Posted by: Jason McKerr
- Posted on: May 01 2001 00:35 EDT
- in response to Steve Chernyak
I usually have a properties or XML file with various application properties in it. However, there are many ways to do this. One of the most common properties that I use is the application name. As for getting the application name directly from the servlet engine, I don't know, never tried. Here is a good article be Sean Neville on how to use Properties files or XML files.
-Newt -
Getting web app name[ Go to top ]
- Posted by: Jason McKerr
- Posted on: May 01 2001 00:36 EDT
- in response to Steve Chernyak
oops, really, here's the URL this time
http://developer.java.sun.com/developer/technicalArticles/xml/metadata/ -
Getting web app name[ Go to top ]
- Posted by: Geoffrey Wiseman
- Posted on: May 01 2001 07:07 EDT
- in response to Steve Chernyak
For what it sounds like you want, request.getContextPath( ) should get you what you need.
-
Getting web app name[ Go to top ]
- Posted by: Bhargav Srirangam
- Posted on: May 01 2001 10:36 EDT
- in response to Geoffrey Wiseman
Hi,
I am using web macro's as UI( this is the first time i am using and still learning) and servlets to do my back end job, i need to retrieve my servlet URl so that i can automate my app to run on any application server, i am able to retrieve the URI but not the URL from my request object, where am i doing wrong, i have tried all the possible combinations of methods but still finding it hard to achieve, help me out.
thanks for ur time
-
Getting web app name[ Go to top ]
- Posted by: Bhargav Srirangam
- Posted on: May 01 2001 10:40 EDT
- in response to Steve Chernyak
Hi,
regarding the question how to retrieve URI of ur web app, from servlet/JSP
HttpServletRequest req;
String URI = req.getRequestURI();
should do the job of identifying the servlet URI or ur web app path.
-
Getting web app name[ Go to top ]
- Posted by: Steve Chernyak
- Posted on: May 01 2001 12:26 EDT
- in response to Bhargav Srirangam
Thank you all for your responses.
The request.getContextPath() was exactly what I was looking for.
Thanks, Steve