Getting the absolute or relativ (file)path to servlet location

hi
my servlet needs to create some files. thatfor i need a reference location such as the root of the webapp dir or the location of the servlet or something like this, so i can build the paths relative to the servlet/webapp location.
is there a way to get this information? i just read the servlet api docu and couldn't find a appropriate methode. Only thing i found out is that the Fileobject seems to create relative paths from the bin dir of my tomcat installation.... but that's not very usefull.
any ideas? how do you solve that problem?

Ok... the getResource() method returns jndi:localhost/examples/... but I'm not sure the jndi: is what I want or what will work. The getRealPath() method is not bad, I can save to files using my Tomcat Server. I just was not expecting it to get the harddrive location instead of the URL location. Does anyone know if using this harddrive location will work when loaded onto a real webserver and no longer Tomcat? If it will then great!

Similar Messages

  • How to get the loaded client sequence file path/name?

    I added a step in Process model, and wanted to get currently loaded client sequence file name/path. I used the variable of "SequenceFile.Path" but then I realized what I would get is the process model file path, not loaded client sequence file path/name. How can I get loaded client sequence file path/name?
    Thanks!
    Jacky

    I dont understand what you are trying to achieve.  Can you provide more information.
    If you are trying to dynamically load and run a client sequence file at run time you need to make a couple of calls to the TS API from inside the process model, Engine.GetSequenceFileEx to get a reference to your sequence identified by its pathname, and then Execution.ClientFile to tell the process model which sequence you want to run.
    Steve
    There are 10 types of people in the world that understand binary, those that do and those that don't.

  • How to get the absolute path of a file from the local disk given the file n

    how to get the absolute path of a file from the local disk given the file name

    // will look for the file at the current working directory
    // this is wherever you start the Java application (cound be C: and your
    // application is located in C:/myapp, but the working dir is C:/
    File file = new File("README.txt"); 
    if (file != null && file.exists())
        String absolutePath = file.getAbsolutePath();

  • To get the absolute path of a file in JSP

    Hi,
    I want to include a HTML page in a jsp.The path of the jsp should not be hot coded.So that i can get the path from the jsp file i am running and then concat the correspondinghtml file name to the absolute path of the jsp file i am running.What can i do to get the absolute path of the jsp file.

    I dont know if there is a way to get the path of the current jsp - but you sure can get the path to your web application using the ServletContext's getRealPath() method and then if you have stored the html (say x.html) in a folder (called, say 'static') immediately under your application root,
    String contextPath = application.getRealPath("/"); //path to your application ctxt
    String htmlFilePath = contextPath.append("/static/x.html");ram.

  • Getting the absolute path of the current executing file

    I have a file which will be placed in window and linux environment. It is not good to change the source code in that way:
    String path = "D:\\java\file1.txt"; (Window)
    String path = "/java/file1.txt"; (Linux)
    So I would like to ask how to get the absolute path based on that executing file?
    I referred to the reference in jsp, but I don't know what class and the coding syntax in console environment.
    Thx for any help.

    If you are looking to "get" a file that is located in a directory with (or somewhere under) the class file than use
    myClass.getClass().getResource(<relativePathWithFileFromClass>);  //URL
    myClass.getClass().getResourceAsStream(<relativePathWithFileFromClass>);  //InputStreamAs far as determining which Operating System you are on, there are a number of environment variables that will tell you that, and you can then format your file path accordingly.
    You can use "/" in your path regardless of which OS you are using. You do not have to use "\\" on Windows (excpet maybe inside of a Runtime.exec command string).
    Here is a very small program you can compile and run if you wish to see the list of System Properties available:
    public class ShowProperties {
      public static void main(String[] args) {
        System.getProperties().list(System.out);
    }Just save that to a file (named ShowProperties.java of course) and compile and run it, and you will get a list of your available System Properties and their current values

  • How to get the absolute path of logicalhost server domain on Windows Sun

    i am reading a file from Xsql Folder, that is located in the logicalhost Sun\AppServer\domains\domain1\applications\j2ee-apps.(IN Sun Application Server)
    I am pretty sure that using the absolute path will solve this issue, so my first question is: How to get the absolute path of logicalhost server domain on Windows?
    i tried with System.getProperty("com.sun.aas.instanceRoot").
    but i am able to retrive Sun\AppServer\domains\domain1 upto this .i am unable to retrive Sun\AppServer\domains\domain1\applications\j2ee-apps.
    please suggest me how u can get absolute path in sun application server

    Take a look here

  • How to get the absolute path of logicalhost server domain on Windows?

    My logicalhost server domain behaves strangely. I am reading a file from collaboration definiton, that is located in the logicalhost/is/domains/domain1/config folder. I thought, that this folder is used as an application root folder so I can read files like ./file from there. And it worked.
    But then I've installed the domain as a Windows service, restarted the PC. When the domain1 gets started, I get exceptions saying that the file can't be found. Then I restart the domain (in domainmgr.bat) and it works again.
    I am pretty sure that using the absolute path will solve this issue, so my first question is: How to get the absolute path of logicalhost server domain on Windows?
    And my second question is: Why does this happen?

    The default folder for a Windows Service is the system32 folder contrary to the instance root folder when starting it as a normal process.
    That's the why, haven't tried the how, but you should be able to get the value by calling System.getProperty("com.sun.aas.instanceRoot").
    Hope this helps
    Paul

  • How to get the absolute path of a DTD referenced in an XML?

    Hello!
    My OS is Windows.
    I use "org.apache.xerces.parsers.SAXParser" which implements LexicalHandler to parse XML files. When method "startDTD" starts and "systemId" is got, how can I get the absolute path? Is there any simple way?
    Regards!

    Hi,
    http://forum.java.sun.com/thread.jsp?forum=34&thread=36
    612The methods in the above topic seem to be available when use a DOM parser..

  • Siebel 8.0.0.12 Fix Pack; Unable to get the seed from binary file.

    Hello Folks,
    Can anyone throw some light into what action is required on my scenario.
    I have applied Fix Pack Siebel 8.0.0.12 on top of 8.0.0.11 SBA. After it is appled, I am facing a documented issue within the Release Notes for the 8.0.0.12 Fix Pack
    The issue is "UNABLE TO LAUNCH URL AFTER APPLYING SIEBEL 8.0.0.12". I tried the steps given with the MR document, however, I am still having this issue.
    I am also not sure what is expected at the step of; Run the following command: seedgeneratorutil myseed.dat abcdef .
    It's asking me for a value to enter for seed at command prompt. "Enter the seed":
    what I should give here. As an assumption values,I gave SADMIN and tried to launch but still shows up the same error
    Please Assit
    Steps Details from Release Notes:
    UNABLE TO LAUNCH URL AFTER APPLYING SIEBEL 8.0.0.12
    Component: Server Infrastructure
    Subcomponent: SWSE
    Product Version: Siebel 8.0.0.12
    Base Bug ID: 11938270
    **Users are unable to launch the URL after applying the Siebel 8.0.0.12 Fix Pack.
    **Use the following workaround to address this issue:
    Navigate to the eappweb/bin directory from the command line on the SWSE installation.
    Run the following command:
    seedgeneratorutil myseed.dat abcdef
    NOTE: In the example, myseed.dat is a filename. You can give any file name you wish.
    The myseed.dat file is generated in the eappweb/bin directory.
    Edit eapps.cfg to include the following parameters under the SWE section:
    seedfile = < complete path for myseed.dat >
    Bounce the web server.
    (For Linux only) Copy libmod_swe.so from the eappweb/bin folder to the web/ohs/modules folder
    Thanks
    Kumar

    Wilson,
    Thanks for your reply.I have repeated the steps and regenerated the error messages.
    Browser
    Message:
    An error occurred while trying to process your request. This error indicates a problem with the configuration of this server and should be reported to the webmaster (along with any errors listed below). We apologize for the inconvenience
    Initialization error:
    Unable to get the seed from binary file.
    Log
    2021 2011-09-20 23:23:01 0000-00-00 00:00:00 +0530 00000000 001 003f 0001 09 ss110920_7068 7068 7852 E:\sba80\SWEApp\log\ss110920_7068.log 8.0.0.12 [20444] ENU
    ProcessPluginState     ProcessPluginStateError     1     000000024e781b9c:0     2011-09-20 23:23:01     7852: [SWSE] Unable to get the seed from binary file.
    Eapps.cfg
    [swe]
    Language = enu
    Log = errors
    LogDirectory = $(SWSERoot)\log
    ClientRootDir = $(SWSERoot)
    SessionMonitor = False
    AllowStats = true
    LogSegmentSize = 0
    LogMaxSegments = 0
    DisableNagle = False
    seedfile = E:\sba80\SWEApp\BIN\80012seed.dat
    Thanks
    Kumar

  • How to get the URI of a file in a WAR

    Hi all,
    I have a deployed WAR.
    One of its files need to get the URI of another file in this war.
    In exploded format, application.getRealPath(thefilename) would do the
    trick. But it failed if the application is deployed in WAR archive.
    What's the workaround ?
    Note that I need the full path of the file since I need to read its
    content and parse it as XML using DOMParser that requires the full URI ..
    Any help appreciated ..
    mona

    I have a piece of code that does this that looks like this:
    InputStream inStream =
    <ServletClassName>.class.getResourceAsStream("/foo.xml");
    InputStreamReader inReader = new InputStreamReader(inStream);
    And 'foo.xml' is put in the classpath either by placing it in a .jar file in
    the WEB-INF/lib directory or by placing it in a .jar file that is deployed
    with the webapp .war file in an .ear file and then referenced by the
    'Class-Path:' manifest directive in the META-INF/MANIFEST.MF file of the
    webapp.war file. Both ways work. I would think you could put 'foo.xml' in the
    WEB-INF/classes directory and that work work, too. But, I haven't tried that.
    Bill
    Mona Ramlawi wrote:
    Hi all,
    I have a deployed WAR.
    One of its files need to get the URI of another file in this war.
    In exploded format, application.getRealPath(thefilename) would do the
    trick. But it failed if the application is deployed in WAR archive.
    What's the workaround ?
    Note that I need the full path of the file since I need to read its
    content and parse it as XML using DOMParser that requires the full URI ..
    Any help appreciated ..
    mona

  • Getting the error "Cannot copy file GEARAspiWDM.sys." while installing iTunes

    I am installing iTunes on my PC (Windows XP) but I am getting the error "Cannot copy file GEARAspiWDM.sys." but the path is correct and I can copy it manually. Help!

    Hello LondonMom,
    Sorry to hear that iTunes is not installing properly.  I found an article that has steps for troubleshooting iTunes installation issues on a Windows computer:
    Trouble installing iTunes or QuickTime for Windows
    http://support.apple.com/kb/HT1926
    I recommend starting with the section titled "General installation troubleshooting" and then continue with the section titled "Additional troubleshooting" if the error persists. 
    I hope this helps!
    Best,
    Sheila M.

  • Plz help to get the tag of html file

    hi
    I wants to convert the HTML file into PDF file dynamically.
    So first i wants to get the tag of html file when we pass the path of html file.
    so how i do this plz help me.

    Plz Tell me how I get the HTML Tag through the java code.

  • Get the directory where application files exist.....

    Hi ,
    How to get the directory where application files exist....????
    I have found a way....such as:
    Right - click on the application name ... on the pop-up menu... select "Add to <application_name>" and then on the window appeared... i get the dir on the title of this window....
    Is there any simpler method to obtain the dir...????
    NOTE: I use JDev 10.1.3. on windows XP platform...
    Many thanks ,
    Simon

    hi Simon
    If you not only want to see the path, but also want to copy-and-paste it, you can use the "Edit > Copy Path" (Ctrl+Shift-C) menu item.
    success
    Jan Vervecken

  • How can I get the size of a file with apple script

    I try to get the size of a file within an apple script. But I did not find information how to do this.

    There are two ways. I think Apple is moving toward using System Events, which is listed first.tell application "Finder"
    set myFile to selection as alias
    --this just gets a file for me to work with
    --coercing it into an alias is required for the other functions
    end tell
    tell application "System Events"
    get size of myFile
    end tell
    set myInfo to (info for myFile)
    get size of myInfo

  • I have tried to view videos created in premiere elements 10 and I get the following message: "this file type is not supported, or the required codec is  not installed.  When it opens there is a red screen in the monitor panel with Korean writing which als

    I have tried to view videos created in premiere elements 10 and I get the following message: "this file type is not supported, or the required codec is  not installed.  When it opens there is a red screen in the monitor panel with Korean writing which also appears in the place of each clip in the video.  I tried uninstalling and reinstalling premiere elements 10, but that did not have any effect on the video.  Do you have any suggestions?  I researched codec, but do not understand them at all.

    gloucester
    In case you did not find it, the following is a copy/paste of the Announcement on Premiere Elements 19/NVIDIA GeForce
    that appears at the top of this forum.
    Premiere Elements 10 NVIDIA Video Card Driver Roll Back
    If you are a Premiere Elements 10 user whose Windows computer uses a NVIDIA GeForce video card and you are experiencing
    Premiere Elements 10 display and/or unexplained program behavior, then your first line of troubleshooting needs to be rolling
    back the video card driver version instead of assuring that it is up to date.
    Since October 2013 to the present, there have been a growing number of reports about display and unexplained workflow
    glitches specific to the Premiere Elements 10 user whose Windows computer has a NVIDIA GeForce video card. If this applies
    to you, then the “user to user” remedy is to roll back the NVIDIA GeForce video card driver as far as is necessary to get rid of
    the problems. The typical driver roll back has gone back as far as March – July 2013 in order to get a working Premiere
    Elements 10. Neither NVIDIA nor Adobe has taken any corrective action in this regard to date, and none is expected moving forward.
    Since October 2013, the following thread has tried to keep up with the Premiere Elements 10 NVIDIA reports
    http://forums.adobe.com/thread/1317675
    Older NVIDIA GeForce drivers can be found
    http://www.nvidia.com/Download/Find.aspx?lang=en-us
    A February 2014 overview of the situation as well as how to use the older NVIDIA GeForce drivers for the driver roll back can be found
    http://atr935.blogspot.com/2014/02/pe10-nvidia-video-card-roll-back.html
    ATR

Maybe you are looking for

  • Variable being lost after CONNECT BY...PRIOR query

    Im having an issue with the following code (snippet posted): SELECT ewpm_project_id INTO pro_id FROM ewpm_work_package WHERE ewpm_work_package_id = wp_id; --can return pro_id here SELECT ewpm_work_package_prefix, LEVEL INTO parent_prefix, parent_leve

  • Mouse from arrow to hand

    How do you change the mouse from an arrow to hand when mouse is over a button or a data list component? Is there a way to do this in the UI of Catalyst and if not... how do I do it in Flash Builder? --- Andrae.

  • After (or while) running firefox one certain game locks up computer

    This occurs with only one specific game. I can play the game after I boot up the computer. If I have run Firefox (or am still running it) then try to sart this game the computer completely locks up and I have to turn the power off to restart the syst

  • Premiere Elements 10 Help

    I recently downloaded Adobe Premiere and Photoshop Elements 10. I started with Disc 1 with Premiere. It won't leave the "New Project" faze. I have Windows 7, so I then realized I was supposed to start with Disc 2. I started with disc 2 on Photoshop,

  • VF31 Billing document Spool

    Hi all, I have problem with invoice spool. VF31 Invoices are spooled by SAP as one spool file per invoice document. My requirement is to create only one spool file for all invoices instead of one spool request for one invoice. Any idea how to group a