How to avoid giving absolute path?

Hi
I have a web application which contains some jsps and servlets and i am running it on Apache Tomcat 4.1. The name of my application is MyApp which contains all the servlets and jsps.
In order to deploy the application i have placed the MyApp folder in the 'webapps' folder of Tomcat. Now in one of my servlets i.e. 'DirectoryCreator', i am trying to create a folder i.e. 'Directory' in the MyApp folder. The problem is that i dont want to give an absolute path to the File class constructor. The class files of my servlets are in classes folder i.e. MyApp \ Web-INF \ classes.
I have tried:
File f = new File("/Directory");
f.mkdir();but this creates the Directory folder in my C drive.
Please tell me how i can avoid giving the absolute path.
Thanks.

What you want is getSerlvetContext().getRealPath("WEB-INF/NewDir").
If you're going to put extra data into your webapp you should put it in WEB-INF unless you want it to be avaialble to be served e.g. html files etc.

Similar Messages

  • 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 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();

  • 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..

  • How to find the absolute path of file  which store in KM foler ?

    Hello everyone:
         We want to develop an ABAP program which can write files into KM folder directly.
         So I need to find the absolute path of file which store in KM folder first, then we can consider the develop solution.
         Is this issue possbile that an ABAP  program write files into KM folder  directly ?
         Is there anybody had done this job ?
    Best Regards,
    Jianguo Chen

    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..

  • Ora:readFile error when giving absolute path, error ORABPEL-05002

    When I try to read file by providing the absolute path:
    using ora:readFile('file:///share/tripti.txt'), exception is thrown
    The filepath is accessible through the browser.
    <2008-06-03 12:32:23,234> <ERROR> <default.collaxa.cube.engine.dispatch> <BaseScheduledWorker::process> Failed to handle dispatch message ... exception ORABPEL-05002
    Message handle error.
    An exception occurred while attempting to process the message "com.collaxa.cube.engine.dispatch.message.invoke.InvokeInstanceMessage"; the exception is: XPath expression failed to execute.
    Error while processing xpath expression, the expression is "ora:readFile('file:///share/tripti.txt')", the reason is message can't be null.
    Please verify the xpath query.
    ORABPEL-05002
    Message handle error.
    An exception occurred while attempting to process the message "com.collaxa.cube.engine.dispatch.message.invoke.InvokeInstanceMessage"; the exception is: XPath expression failed to execute.
    Error while processing xpath expression, the expression is "ora:readFile('file:///ossi-1193/share/tripti.txt')", the reason is message can't be null.
    Please verify the xpath query.
         at com.collaxa.cube.engine.dispatch.DispatchHelper.handleMessage(DispatchHelper.java:171)
         at com.collaxa.cube.engine.dispatch.BaseScheduledWorker.process(BaseScheduledWorker.java:70)
         at com.collaxa.cube.engine.ejb.impl.WorkerBean.onMessage(WorkerBean.java:86)
         at sun.reflect.GeneratedMethodAccessor47.invoke(Unknown Source)
    Pl. throw more information on what could be the issue.

    hi kamran,
    Thank u for u r reply. I did't understood where to change the database identifier in tnsnames.ora. sorry for tell like this i am new for oracle. And name shall give. The tnsnames.ora look like this:
    # tnsnames.ora Network Configuration File: D:\oracle10g\NETWORK\ADMIN\tnsnames.ora
    # Generated by Oracle configuration tools.
    T2 =
    (DESCRIPTION =
    (ADDRESS_LIST =
    (ADDRESS = (PROTOCOL = TCP)(HOST = HA14)(PORT = 1521))
    (CONNECT_DATA =
    (SERVER = DEDICATED)
    (SERVICE_NAME = T2)
    OMCX =
    (DESCRIPTION =
    (ADDRESS_LIST =
    (ADDRESS = (PROTOCOL = TCP)(HOST = HA14)(PORT = 1521))
    (CONNECT_DATA =
    (SERVER = DEDICATED)
    (SERVICE_NAME = OMCX)
    ZEN2K7 =
    (DESCRIPTION =
    (ADDRESS_LIST =
    (ADDRESS = (PROTOCOL = TCP)(HOST = vsnet1)(PORT = 1521))
    (CONNECT_DATA =
    (SERVICE_NAME = zen2k7)
    OVSL06 =
    (DESCRIPTION =
    (ADDRESS_LIST =
    (ADDRESS = (PROTOCOL = TCP)(HOST = HA14)(PORT = 1521))
    (CONNECT_DATA =
    (SERVER = DEDICATED)
    (SERVICE_NAME = OVSL06)
    EDMS =
    (DESCRIPTION =
    (ADDRESS_LIST =
    (ADDRESS = (PROTOCOL = TCP)(HOST = HA14)(PORT = 1521))
    (CONNECT_DATA =
    (SERVER = DEDICATED)
    (SERVICE_NAME = EDMS)
    EXTPROC_CONNECTION_DATA =
    (DESCRIPTION =
    (ADDRESS_LIST =
    (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC))
    (CONNECT_DATA =
    (SID = PLSExtProc)
    (PRESENTATION = RO)
    )

  • How do you convert absolute paths to external files to relative paths?

    I have a TOC PDF document that contains approximately 200 links to other external PDF files. The other files are located in the same directory as the linking PDF. However, when the links were done, I accidentally created the links in a copy of the PDF on the file server, *not* the one in the same directory as the target PDFs.
    So now the links in the TOC PDF all have an absolute network path embedded in the link such as "/D/projects/assets/PDF/targetFile.pdf", whereas they should only be "/targetFile.pdf". Is there a way to easily change these? I don't relish the notion of having to walk through the document and manually fixing each one.
    I tried forceably editing the PDF file in a binary editor, but this caused the document structure and fonts to get out of whack -- though the links worked.
    Any recommendations? I will consider a commercial product if one exists!
    Thanks,
    Rob

    I think you are barking up the wrong tree...
    Let's say you have a 10 second clip of PAL material:
    10 seconds x 25 fps = 250 frames
    If properly converted to NTSC:
    10 seconds x 30 fps = 300 frames
    The only difference is the number of frames, NOT THE LENGTH OF THE CLIP! It is still 10 seconds long.
    10 seconds of audio x 44.1 kHz = 441 thousand samples
    or
    10 seconds of audio x 48 kHz = 480 thousand samples
    or
    10 seconds of audio at 22.05 kHz = 220.5 thousand samples
    The only difference is the number of samples. NOT THE LENGTH OF THE AUDIO. It is still 10 seconds long.
    If you have drift, then there is something wrong in your conversion. You can't take a 25 fps clip, tell it to play at 30 fps and expect it to be the same length. There are multi-thousand $$$ transcoders that do that job.
    HTH,

  • How to avoid giving credit card number

    i dont want to give my credit card number when confirming my apple id what do i do

    - Redeem and iTunes gift card
    - Create a NEW account using these instructions. Make sure you follow the instructions. Many do not and if you do not you will not get the None option. You must use an email address that you have not used with Apple before.
      Creating an iTunes Store, App Store, iBookstore, and Mac App Store account without a credit card

  • How can I get the server absolute path of virtual directory?

    Problem context:
    absolute path of my application at JRUN server is
    c:\testing
    nd url is
    http://kaspak/test
    ( kaspak is a machine local to server i-e client nd server r at same machine )
    I m uploading a file nd saving it at server.
    PROBLEM:
    server save my uploaded file at
    C:\Program Files\Allaire\JRun\servers\default
    [ a path where server is installed ]
    while I want to save it at directory
    c:\testing\uploadfiles
    How can I achieve this???
    waiting for quick reply..
    KasPak

    here is a function for which u said,
    protected void readAndSaveFile(MultipartInputStreamHandler in,
    String boundary,
    String filename,
    String contentType) throws IOException
    A utility method that reads a single part of the multipart request that represents a file, and saves the file to the given directory. A subclass can override this method for a better optimized or differently behaved implementation.
    again saving a file, or uploading a file is no problem,
    but saving a file at our desired location,
    nd this can only be done if we know reall/absolute path of our application at server,
    i-e we need an API which can tells the absolute path of our application.
    e.g
    our application url is http://kaspak/testcode
    we need its absolute mapping to directory on server
    e.g it it is at c:\testcode
    if we get the absolute path then we can pass it in above function or in File class constructor.
    isn't it??
    I think in this way i can save file at other location.
    But how i can get absolute path?????
    thanks for ur reply,
    nd waiting for ur reply again.
    wbw
    kaspak

  • How to get rejected file absolute path location in file rejection handler

    HI,
    Right now I am working in the below scenario in SOA11G.
    1) Create a file adapter service and wire it to a BPEL process.
    2) Create a Fault-policies file where we have referred a Java Action as a Fault policy.
    3) Refer that fault-policy to the Fault-Binding file and put both the file in the same directory with composite.xml file.
    4) So when any rejection message happened with any wrong incoming file, the Java Action is getting called.
    But as per my requirement I want to get the absolute path of the incoming file in my java action, so that I can write some other logic to copy that file to some other location.
    So is there any API available to achieve this or any logic about how to get the absolute path of a rejected file at runtime.
    Regards,
    Tripathy.

    Hi Omar,
    You need to use OPEN_DATASET & READ DATASET statements to get the file from application server.
    Steps:
    Open dataset in read mode
    Read the data set and collect into internal table
    Now, convert this into XSTRING by using function module SCMS_STRING_TO_XSTRING
    After converting into XSTRING, you can use CL_WD_RUNTIME_SERVICES=>ATTACH_FILE_TO_RESPONSE to download into local system
    Please refer the below links
    Upload File from SAP Application Server using ABAP
    Application Server Program - ABAP Development - SCN Wiki
    Hope this helps you.
    Regards,
    Rama

  • Absolute path of server

    hi!
              does anyone can tell me how to get the absolute path of the server from a
              virtual path
              thax
              

    I'm not quite sure I understand your question, but in case I do, here goes. If you're ssh'd into another machine, you're using that machine. Dragging something from your local finder into a terminal ssh session, if I'm not mistaken,hopelessly munges the path. The ssh session puts you on the other client. Trying to figure out what happens when you drag a file from your local finder to a terminal session on a remote host starts to make my head hurt. I think typing the entire path, or just navigation to the right directory would be the best bet. You can do this on multiple clients through ARD, and I imagine you could script the process as well (already posted).

  • 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 can you determine the absolute path to a dynamically created NetStream object?

    We are trying to implement video captioning with a freeware component, ccforflash. This requires us to provide an absolute or relative path  to our NetStream object. How can we determine this path in Flash CS5 AS3?
    From the CCforFlashCS5 documentation:
    "2. Object name and path
    Type the name and path.  This is the instance name of the object with which CCforFlashAS3 will synchronize. It must be spelled correctly, since CCforFlashAS3 will query the object with this name for timing information in order to synchronize the captions. The path must also be included; either relative to the CCforFlashAS3 component (i.e. this.parent) or the absolute path from the main level of the movie (root)."

    It would be easier if the NetStream object was created on an easily identifiable place on the timeline. This player has an MVC architecture. The NetStream object is created in a subclass to Model class, which is itself a subclass of the EventDispatcher object. The View class access it via an interface.
    As you can guess, it's not that straightforward to determine where the NetStream object is located on the timeline. This is compounded by the fact that the NetStream object does not have a name property.
    I've tried methods like these, but they only work for the DisplayObject class:
    public static function displayObjectPath( avDisplayObject : DisplayObject ) :String
    var lvPath:String = "";
    do
    if( avDisplayObject.name ) {
    // var obj_name:String = (avDisplayObject.name == 'root1') ? 'root' : avDisplayObject.name;
    if (avDisplayObject.name != 'root1') {
    lvPath = avDisplayObject.name
       + ( lvPath == "" ? "" : "." + lvPath );
    } else {
    trace("displayObjectPath() NO NAME avDisplayObject="+avDisplayObject);
    } while( avDisplayObject = avDisplayObject.parent );
    return lvPath;
    } // displayObjectPath
    private  function showChildren(d:DisplayObjectContainer):void {
    trace("showChildren()");
    if (d.numChildren>0) {
    for (var c:Number = 0; c < d.numChildren; c++) {
    trace("showChildren c=",c," name=",d.getChildAt(c).name);

  • How to read images in jsp from an absolute path not from the web app?

    hello there
    i want to read images from an absolute path on the hard disk not from the images folder in the web application
    how to do that?
    thank you

    Ok. You don't give the servlet the full path of an image. You just give an image id in query string. E.g.
    http://my.server.com/imageServlet?id=12Id can be whatever: number as well as name.
    Then, in your servlet You get this id, then read an image file that is mapped for this id and sends it to browser via servlet output stream.
    On the jsp page you write sth similar to:
    <img src="http://my.server.com/imageServlet?id=12"/>and your image will be displayed using your servlet. The image file path is needed only in the servlet code to open the stream to file (image file can be stored wherever you want in file system), read it and write to output stream. Read the tutorial accessible via link I provided in the previous post.

Maybe you are looking for

  • Using time capsule to extend a network with security

    I have a time capsule and my roommate and I use the same wireless network. I want to add my time capsule to the network we both share but want to be sure only I will be able to access data on my time capsule i.e. external hard drive, back ups etc.  I

  • Query running error

    Hi, all. In our PROD system we faced one problem. When we run query we get error "Cannot create characteristic combination: type \BI0\0100000100" doesn't exit" "Special situation CX_SY_CREATE_DATE_ERROR" I think we have problem with temporary databas

  • Auto shutdown w/75% battery after 10.4.11 Intel update

    First, let me say, I am not too computer savy for anything other than the basics. After installing the latest Mac OS X Update (Intel) my laptop has become somewhat unstable, needing to be restarted several times and freezing up twice needing a forced

  • Eclipse Galileo 3.5 Cocoa 32/64 bit + Flash Builder = fail?

    I thought I'd just bring this to everyone's attention, since it came up as a "gotcha" to me.  If you're downloading the newest version of Eclipse and you want to plug Flash Builder Beta 2 into it, you can only use the Carbon version. Any word on what

  • Please Read Msi.. My Kt8neo Damage 2 Hdd Disk 120 Gb Sata

    Hello, i need help!........i have KT8NEO2FISR, but its damage MY new hdd disc sata 120 gb seagate 8MB..................after 1 month i change waranty my hdd disc by other same but my kt8neo again damage my new disc serial ata 120 gb seagate I have sa