Getting web app name

Discussions

Web tier: servlets, JSP, Web frameworks: Getting web app name

  1. Getting web app name (6 messages)

    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

    Threaded Messages (6)

  2. Getting web app name[ Go to top ]

    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
  3. Getting web app name[ Go to top ]

    oops, really, here's the URL this time

    http://developer.java.sun.com/developer/technicalArticles/xml/metadata/
  4. Getting web app name[ Go to top ]

    For what it sounds like you want, request.getContextPath( ) should get you what you need.

  5. Getting web app name[ Go to top ]

    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
  6. Getting web app name[ Go to top ]

    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.

  7. Getting web app name[ Go to top ]

    Thank you all for your responses.

    The request.getContextPath() was exactly what I was looking for.

    Thanks, Steve