How to get the web application root ?

Hi,
We are developing a JSP/Servlets web application for Weblogic 5.1, that is distributed as a WAR archive, and so far we are unable to determine the web application root dynamically (from within the code in a Servlet or class). We tryed the servletContext.getRealPath("/") method, but it is not working due to the fact that we are deploying the application as a WAR file.
We need to have this app root at the application startup, because it is widely used inside the JSP pages and the servlets of the web application. Also we would like to avoid setting it as a static parameter in the web.xml or elsewhere.
Does anyone know how to do that? Any hint or suggestion is very much appreciated!
TIA
Stefan Buynov

Thanks for your reply.
As I said in one of my early posts, this variable (the application root) i used widely in the application (not only in JSPs, but also in classes).
Another problem will be including JSTL in the project - first of all, I will have to put this tag where the variable is required (it will be quite exhausting), and also the specification of the application is strict - I might not be able to add this tag library, since the client won't like it.
Anyway, thanks for your concern.
Regards,
Stefan

Similar Messages

  • How to get the current application root directory

    Hi Experts,
    I am deploying an ADF Application to a Standalone WLS 10.3. During development I am using Integrated WLS (which comes with JDeveloper 11.1.1.5.0). During development, I configured my application to create log files in my local machine (where Integrated WLS is running) by using absolute path for my log file. Now, I am moving to a standalone instance of WLS for testing (before moving to production).
    Now I need to keep my log files under my application root directory. Please let me know how to get the absolute path of the deployed application root directory from WLS ENV/System property into my application's Java Code.
    I tried the below java code,
    Current weblogic server name is: " + System.getProperty("weblogic.Name") --> This gives me the name of the server where my application is running.
    Current weblogic server name is: " + System.getProperty("weblogic.Root") --> This returns NULL. How to get the Root directory of my application using some system property inside my application at runtime??
    Thanks
    Rathnam

    One method is to create a File(""); and do getPath() on it.
    At least it's worked for me.

  • The web application root or the URL is invalid?

    Hey there-  So basically I'm setting up a simple ASP.NET FB4 project using IIS locally.  Before I get into my question, I can successfully create the project and test it on my machine.  My concern is that I can not receive a valid confirmation from FB when setting up the configurations.  For instance, if I place the correct paths:
    Web application root: C:\inetpub\wwwroot\weborb4
    Web application URL: http://localhost:1234/weborb4
    I always receive this error, The web application root or the URL is invalid.  Is there something I should be looking into?  Any suggestions are appreciated!

    Hi
    I filed the bug http://bugs.adobe.com/jira/browse/FBG-2539 for the same

  • How to get the active application users IP address in R12 by sql command

    Hi ,
    I need to know how to get the active application users IP in R12 by sql command
    in order to kill any session by the IP address ?
    Am working on 12.1.3 Application
    And 11.2.0.3 Oracle Database
    Thanks

    936921 wrote:
    Am still couldn't found the IP address for the connected Application users.
    If there any select statement can help me with that?
    Really? Then how do you explain me finding the following docs from the links I referenced above?
    How To Find The IP Address Of The Client Machine From Where A Particular Forms User Is Connected ? (Doc ID 879092.1)
    How to Track IP Address of the Form Session in Oracle application 11i (Doc ID 878931.1)
    Where to find the Client IP Address for a Client in E-Business Suite? (Doc ID 1258415.1)
    How To Get The terminal ID For The Machine From Which A User Is Logged To E-Business Suite Applications (Doc ID 751658.1)
    Thanks,
    Hussein

  • How can I get the web application's context root?

    I have a web application, which is defined in Tomcat's server.xml:
    <Context path="/cbes" docBase="e:\work\GM\code\CBESCurrency" debug="0"
    reloadable="true" crossContext="false"/>
    And I hava a servlet in this web application.
    How can I get the context root of the web application?
    in this example: reture should be "cbes" or "/cbes"
    how?
    thanks alot.

    getContextPath() in javax.servlet.http.HttpServletRequest

  • How do you get the web application path from the servlet?

    I have created a web application which is installed in
    /webapps/myApplication
    /webapps/myApplication/data/users.xml
    /webapps/myApplication/WEB-INF/classes/myServlet
    How can you get the path to the "users.xml" file from the "myServlet" file?
    The code below doen's seem to return the xml file. anybody knows why?
    public class myServlet extends HttpServlet {
    public void doGet( HttpServletRequest req, HttpServletResponse res ) throws ServletException, IOException
    File myXmlFile = new File("/data/users.xml");

    Try this..
    String FileName = getServletContext().getRealPath("\\data\\users.xml");
    File myXmlFile = new File(FileName);
    hope this helps..

  • Getting the web application name at runtime

    Hello everyone!
    We got a pretty annoying problem here, which has to be solved. We have an online application running that is our major website. As development continued lots of stuff (completely different functionality) plugged into this application.
    Now we want to devide this huge mixture into "real" J2EE webapps and put them into a new server environment (weblogic 7).
    OK the following prob: The servlets are used by different applications. So they need to forward requests to different paths cause of the different applications.
    We need to determine the name of the application that the servlet is currently running in. Any idea how we could do that?
    Perhaps it is possible to get the documentRoot from web.xml?!
    <context-param>
    <param-name>weblogic.httpd.documentRoot</param-name>
    <param-value>azonline</param-value>
    </context-param>
    But how do we do that either??
    Thx for your help.

    Another sad self-reply :( ->
    Best practice is to use:
    getServletContext().getServletContextName()
    It returns the name determined in the web.xml in tag
    <display-name></display-name>
    Thx to me and all the dukes to me :p!

  • How to get the web of document from the URL

    Hi All,
    Need small help here,
    I have SharePoint doc URL as below:
    http://sharepoint.com/sub1/sub2/sub3/documents/TestFile.docx
    Here, TestFile existed in document library of Subsite i.e. sub3.
    If I give above URL as input, I should be able to get "sub3" web.
    How can achieve this programmatically. Overall we should get the leaf web from the URL.
    Thanks in advance.
    Krishnasandeep

    Hi Sanny521,
    The SPSite constructor does not care when you pass in the document library and filename as part of the url. you can use the following code:
    string myFileUrl = "http://sharepoint.com/sub1/sub2/sub3/documents/TestFile.docx";
    using (SPSite site = new SPSite(myFileUrl))
    using (SPWeb web = site.OpenWeb())
    SPFile file = web.GetFile(myFileUrl);
    string webUrl = web.ServerRelativeUrl;
    You pass the full url into the SPSIte constructor, it will retrieve the site collection, then the OpenWeb call will retrieve the proper web from the already passed full url, then you can retrieve the file and the url of the SPWeb.
    Mathieu Desmarais http://www.matdesmarais.com/

  • How to get the web templates not specific to any locale GetAvailableWebTemplates

    Hi
    I am using spweb.GetAvailableWebTemplates((uint)1033, true) to get all the available web templates. Since i use 1033, i get the en-US site like Teams Site(en-US). But i would like to get the templates with locale not specific to any.
    like Teams site(All)
    How to achieve this.

    Hi,    
    The locale ID specified when a site definition is created which controls the default language used in the corresponding site template.
    If there are no other site definitions created based on other languages, then we can pass the default locale ID(1033) to the
    SPWeb.GetAvalableWebTemplates method, it will retrieve a collection of site templates which are created with locale ID 1033.
    The OOTB Teams Site template is created based on the locale ID 1033, so we can use this ID to retrieve it.
    Best regards
    Patrick Liang
    TechNet Community Support

  • How-to get the JSF application context path?

    I want to do a redirect from within a JSF backing bean. How do I get the application context path?
    I plan to do this in the constructor of the backing beans in order to validate the user has previously logged in.
    public BackingBeanName()
    FacesContext facesContext = FacesContext.getCurrentInstance();
    HttpSession session = HttpSession)facesContext.getExternalContext().getSession(false);
    HttpServletRequest request = (HttpServletRequest)facesContext.getExternalContext().getRequest();
    userid = (String)session.getAttribute("userid");
    if (userid == null) {
    logger.info("userid attribute is not in session");
    ExternalContext ec = facesContext.getExternalContext();
    appContextPath = ???????????????????????;
    String redirectTo = appContextPath + "/logon.jsp";
    try {
    ec.redirect(redirectTo);
    catch (IOException e) {
    String msg = "redirect to " + redirectTo + " failed";
    logger.severe(msg);
    return; // throw an exception instead of return;
    Regards,
    Al Malin

    Frank, your suggestion of using JSF global navigation to the logon page looks like what I need but I need some advice implementing it.
    My backing bean constructor looks like this:
    public Search()
    FacesContext facesContext = FacesContext.getCurrentInstance();
    String userid = GpaUtil.getSessionUserid(facesContext);
    if (userid == null)
    logger.info("session userid not found, going to logon page");
    ??????? What goes here ????????
    ??????? I think I need to fire an event but I'm not sure how to do it, ????????
    ??????? let alone if this is what needs to be done ????????
    ??????? or even if this is the right spot in the code ????????
    gpas = ProductApproval.retrieveList("1=1","1");
    FWIW, the navigation rule looks like this:
    <navigation-rule>
    <navigation-case>
    <from-outcome>goLogon</from-outcome>
    <to-view-id>/logon.jsp</to-view-id>
    </navigation-case>
    </navigation-rule>
    Your help is greatly appreciated.
    Regards,
    Al Malin

  • I want to know how to get the web addresses to go away that appear in the bottom left corner of the browser every time my mouse goes over a link

    Any time that my mouse goes over a link on a web page a little box in the bottom left corner of the browser pops up showing the web address for that link and it is really annoying, especially when i am on facebook because there are so many links on the home page i cant move my mouse anywhere without that box popping up and blocking part of my conversations. I was wondering if there was any way to turn this off. I've checked through the options and to my knowledge there is no way to turn it off. Just wondered if anyone else has had this problem or knew if there was a way to get that box to go away.

    Another option would be to use the following extension to push those messages into the status bar. It could be a convenient way to have your messages visible when you want them, but with less distraction.
    https://addons.mozilla.org/en-US/firefox/addon/status-4-evar/
    If you try it, let us know what you think.

  • How to create the Web application designer

    Hello BW Guru's,
    how to create the WAD... step by step procedure and where to save the report and how to excute the report.
    please send as soon as possible.
    Thanks
    Sudha

    hi,
    you can also refer to the following links.
    http://help.sap.com/saphelp_nw04/helpdata/en/1a/456a3badc1b315e10000000a114084/frameset.htm
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/749a4622-0a01-0010-36bf-b6b30a2a3a22
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/3f11a7e3-0601-0010-52a2-c3fbbdb068da
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/webcontent/uuid/a8cd1f71-0a01-0010-4783-f119b6132d25?rid=/library/uuid/cea68c65-0901-0010-f5a4-fd34189d8078 [original link is broken]
    hope it helps,
    regards,
    Parth.

  • Memory analyzer, how to get the to problem root/object

    Hi,
    I've viewed the live tutorial from https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/f0a5d007-a35f-2a10-da9f-99245623edda.
    My case was, i Dominator Tree, all top ten classes (with 95% retained Heap) were from org.hibernate.*, and only a few of my classes (with 1% retained heap) which were from http request/respond thread.
    Deep into those top classes, it didn't seem to link to my class; however my web app (use jboss, hibernate/ejb3) was runing of memory (GC overhead limit exceed).
    I'm wondering, any other way to find the problem with help of SAP Memory analyzer?
    Thanks
    John
    Toronto

    Hi
    Check out this guide and update the thread thereafter: https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/40244428-5703-2a10-17af-9e878922f900
    Ravi

  • How to get the ownership application

    Hi,
    I am trying to create the ownership applicatoion,
    I have gone to add a new application named it as "ownership" and mentioned the dimension type as Ownership . But in the lat step the system throws an error
    "Required dimension type is missing  I "
    Please help me resolve the issue.
    Thanks
    Navin

    Hi Navin,
    I suggest to follow one of SAP BPC trainings. This will help you to understand the product and it will keep you away by this kind of issues.
    To answer to your question...
    1. You have to create first the dimensions for an application and after that you can create your application selecting the dimensions what you need for that applications.
    Even if you start from RAte application after that you are able to add or to delete dimensions from that application.
    Kind Regards
    Sorin Radulescu

  • Tell me how to get the web search window/bar

    I do not have a web address bar or window. In other words, I am not able to type in a web site address.

    I watched the video and I know what you want.  i'm using iTunes 10.2.2 and I can't install 9.2.1 to check.  However,  think that the instructions I gave you are also valid for iTunes 9.2.1.
    To find the Burn Options, select a playlist and either right-click and select Burn playlist to disc or use the iTunes File menu > Burn Playlist to disc.  Then, your burn options dialog box will appear.
    For the import options, look in iTunes > Preferences > General and click the "Import Settings" button.

Maybe you are looking for