Absolute file path in a war file

Hi,
I have a war file which I have deployed on a Weblogic 7 server.I have a startup servlet which tries to read an xml file located in the WEB-INF folder.I need to have the absolute path to the file so that my parser can read the xml file.
ServletContext.getRealPath() returns null when the application is in a war format.
Would be grateful for any help.
regards
Vikram

I've been using the getRealPath() method from the
ServletContext object to ..
I'm suspicious of the fact that
you are getting a null pointer when you use
getRealPath().
I have also been deploying my webapps to Tomcat using
war files. So without knowing more I'm guessing you
may have some sort of problem with your overall
configuration here...Nothing to do with configuration. getRealPath() returns null if the .war file doesn't get unpacked. The Tomcat servlet engine unpacks the war files but weblogic apparently does not.
So getRealPath() is not generic enough, as it depends on the servlet container used.
Also, I would not recommend the suggestion to use the ProtectionDomain.getCodeSource() method (although it may work). ProtectionDomain is not intended for reading xml files, (wether inside the web-inf dir or not) but has to do with security. It is simply overkill in this case.
The poster should be able to get the file with the class.getResource() method, get a java.net.URL obj out of it, then call URL.getPath() or getFile() (check the URL class for these methods ), get back a path string and call his parser.
The other way would be to simply list that file in the web.xml as an init param :
<context-param>
<param-name>filename</param-name>
<param-value>WEB-INF/file.xml</param-value>
</context-param>and get it with
getInitParameter("filename")

Similar Messages

  • How to get absolute File Path using JFileChooser?

    Hi,
    IS there any way by which we can get the absolute file path ? e.g. If I browse thro JFileUser and Selects "a.txt" and say open, it should return me the complete file
    path e.g. D:/abc/a.txt.
    Present method.fileChooser.getSelectedFile().getName() return the name of the file i.e. a.txt and NOT the complete path.
    Pls Help !!

    fileChooser.getSelectedFile().getAbsolutePath(); will do the trick.

  • Getting absolute file name using af:inputFile

    Hi all,
    Can you help me how to get absolute file name (e.g., C:\Documents\file.txt) using <af:inputFile> component or using any another JSF component.
    Thanks in advance :)))

    we can't get absolute path using inputFile, we can get only the file name. as per my knowledge we don't have any other component also.
    i have one of my requirement i need to read file from specified folder, so i have hard coded my folder name in my managed bean.

  • How to get absolute directory path of a resource?

    Hi,
      I wished to retrieve the absolute directory path of a resource, for example, "demo.test" in the folder of "/document/personal". How to I get the value "/document/personal", is there any IPropertyName i could use?
    Thanks for any suggestions.

    Hi,
    first, the accessRID is the RID which was used at creation time, maybe containing links; these are resolved, so you will get the "physical" place where the file is stored by <i>getRID</i>.
    Second, to determine the path without the name of the file, there are at least three possibilities without looping (resource, the file, is an instance of IResource):
    1.) String path = resource.getParentCollection().getRID().toString();
    2.) String path = resource.getRID().toString().substring(0, resource.getRID()().toString().lastIndexOf('/'));
    3.) String path = resource.getRID()().toString().substring(0, resource.getRID()().toString().length() - resource.getName().length());
    Solution 1 seems to be very intuitive (you ask for the folder path, where the file is in), 2 & 3 are shorter than a loop, but not intuitive and in general dangerous (when using substring, you have to take care of exceptions caused by strange parameters).
    Hope it helps
    Detlev

  • GETTING ABSOLUTE FILE PATH IN FLEX

    Hi,
    I am Facing 2 issues in Flex..
    1) I am not able to import
    flash.fileSystem
    in my MXML Application
    2) Is it possible to get path of file using fileReference. I
    want the path of the selected file
    Can someone please help !!!

    There is no way the Flash Player will open a local file for
    you. Keep in mind that the Flash Player was designed and developed
    for web application - those apps which are served remotely with the
    intention of keeping the data on a server. If you wanted to upload
    your image onto a server, that's fine.
    If you want to store files locally, please look into Adobe
    Apollo. You'll still get to use Flex and Flex Builder. The result
    will be a desktop application with an easy-to-use, operating system
    independent, way to read and write local files.

  • Absolute/Relative Path for elements in xml to rtf template.

    Hi all,
    I have a small doubt, can anyone help me come out of this issue.
    I developed a BI Publisher Report using RTF Template and I am addressing XML elements which are out of the group in the XML file inside the for loop in the RTF template. I am able to get the body of the table but with all blank values on the output.
    I thought to give the full path ie., Absolute path instead only the element name, can anyone suggest me how to address an element outside the group in XML file from a for loop in the RTF template. Is it possible to address like that.?
    Thanks In advance.

    Hi Tim,
    I am using BIP 10.1.3.3.2. I am able to access system variable CURRENT_SERVER URL.
    Steps:
    <?param@begin:CURRENT_SERVER_URL?>
    <xsl:value-of select="$ CURRENT_SERVER_URL"/>
    CURRENT_SERVER_URL is getting printed in BI Publisher. Value displayed is http://xx4697.xxx.co.in:9704/xmlpserver.
    Now we are importing xsl into RTF template. File aaa.xsl is stored at [BIP_Installation_Directory\oc4j_bi\j2ee\home\default-web-app]
    We have hardcoded the path for XSL in RTF. The path is <?import: http://xx4697.xxx.co.in:9704/aaa.xsl?>
    As we want to set dynamic path we changed hardcoded xsl path to <?import: {$CURRENT_SERVER_URL}/../aaa.xsl?> but it is not working. Sometimes BIP is taking local path of MyDocuments folder and sometimes Desktop path. If I put that XSL file in MyDocuments folder or Desktop, it is working fine. But ideally it should refer [BIP_Installation_Directory\oc4j_bi\j2ee\home\default-web-app] path...
    Thanks,
    Amit D

  • Why, since CS6 does DW now use ABSOLUTE image paths when dragging images into Design View from a folder in Finder?!

    While I am grateful the previous issue I had with not being able to drag files into design view at all (in CC and CC2014) was resolved.
    Guys (Adobe), seriously, if you're going to change the functioning of something that used to work just fine, at least supply a way for a user to revert to the old way... I absolutely loathe that I need a legacy version of DW to continue with my current workflow. Please put it back to the way it was, or at least allow a user to chose between the two behaviours.
    If there is a way to do this, without using the Site Manager (which still doesn't work from Finder even with relative to document selected), I would appreciate any guidance.
    As for using the Site Manager (before some smart guy suggests that I just use that) I do not wish to navigate to and create up to 20 "sites" a week and wait for DW to cache them all, when I am already in the folder with the image assets in Finder.
    Also before someone pipes up and says: "You shouldn't be diving sites in design view anyway", I don't... I develop many, many newsletters every week and the folder structure is such that navigation to the actual image folder using the Site Manager would be painful at best.
    I don't really like having to and replace all instances of "file:///Users/me/Work/company/Mailers/Year/wk14/mailer/dev/img/prod5.jpg". It is horrendously wasteful, time-wise.
    Thanks in advance for any helpful replies

    Sorry Murray, DW used to have an idea, my point is that since CS6 its developed a case of Amnesia.
    The "elements" are in the "root" folder as follows:
    newslettername.htm
    img
         imagename.jpg
    So the relative path would be <img src"img/imagename.jpg" />
    However since the change: <img src"file:///Users/me/work/Company/year/week/campaign/img/imagename.jpg" />
    Which is completely useless and needs to be corrected before I upload the html anywhere.
    As for using the site directory, I did answer that in my initial post. I use a laptop, I really don't want a site manager taking half my screen just so I can see the folder structure and navigate with that, especially since I am already at the files I need in Finder.
    Again, this is something that used to work just fine in previous iterations of DW, so I don't believe Adobe is incapable of fixing it nor am I being unreasonable asking for a choice for those that may find the local absolute paths useful in some way. All I want is to be able to chose not to use absolute paths when dragging from Finder.

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

  • Behaviour differences between  war file and exploded directory

    Hi,
    I'm baffled by differences in how my web app behaves when deploy in a war file and when deployed in exploded directory.
    Firstly when I deploy in exploded directory format (using wldeploy in ant) - the jsps do not precompile. However, when I deploy the war file - again using ant and wldeploy - precompile works just fine - and general performance seems better.
    Secondly - the webapp has a pdf file - which is used as a template to dynamically produce a document. When deployed
    in exploded format - the webapp works fine and is able to read the pdf. However, when I deploy in war file, the pdf cannot be read.
    Surely the behaviour should be the same whether we deploy as a war or exploded.
    Someone please help
    Tariq

    Some behaviors will be different between a WAR file deployment and an exploded WAR deployment.
    With respect to JSP precompile, you just say "they do not precompile", so I can't tell anything about that.
    When you read files from an exploded WAR, you can reference them in two ways: as a resource, or as an absolute file path. When you read files from a WAR file, you can only read files as a resource, and not as an absolute file path. You're not giving any information about how you're reading the file, so I can't tell about that either.
    You'd have to provide more detail to get better answers.

  • How can i set a path for my deployment files in weblogic server 10.3

    Hi
    How can i set the path for my WAR ,JAR files while deploying.i am using the wls10.3 version.
    is there any scripts for this ,please provide me.
    my Application is ADF 11g application.

    By "path", I assume you mean "classpath".
    The simplest way is simply to include the jars you need inside the web application or web module's WEB-INF/lib directory, EJB module's META-INF/lib directory, or EAR lib directory.
    If that's not practical, if you use NodeManager to start your servers, you can go to the "Server Start" tab in the server definition in the WebLogic console and edit the "Classpath" field, which defaults to no value. You can specify a classpath value there. Note that if you specify a value there, it REPLACES the default classpath for the server, it doesn't add to it. If you need to just add to it (a much more likely scenario), if the value references the value "$CLASSPATH" in it, that will reference the original classpath value that the server would have had.
    So, for instance, if you wanted to include the MQ jars in the server classpath, you could set a value like this:
    /usr/java/mq/lib/mq.jar:/usr/java/mq/lib/mqstuff.jar:$CLASSPATH

  • How to get the Real Path of a file which is accessed  by URL?

    iam using tomcat6.0.
    I have a file xyz.xml at the top of the webapplication HFUSE which i can able to access by URL
    http://localhost:8080/HFUSE/xyz.xml
    My problem is how to get the realpath of the file "xyz.xml" for reading and writing purposes.
    I tried various things but i could not able to successfully solved the problem?
    1) File f = new File("/xyz.xml");
    print(f.getAbsolutePath()) ============== it is not fetching the file @ http://localhost:8080/HFUSE/xyz.xml rather it is creating a file
    at the root of the drive where eclipse is running.
    2) File f = new File("xyz.xml");============> this is also not working , it is creating the file xyz.xml in the eclipse directory ..................
    Can anyone please guide on this problem?

    RevertInIslam wrote:
    If you want your context root(i.e HFUSE)
    use this:
    request.getContextPath() //where request is HttpServletRequest object to get the needful path.
    e.g:
    File f = new File(request.getContextPath()+"/xyz.xml");//it will create the file inside HFUSE.
    Hope this helps.
    Regards
    BWrong. The File constructor expects an absolute filesystem path. The HttpServletRequest#getContextPath() doesn't return the absolute filesystem path, it only returns the relative path from the current context root. Use ServletContext#getRealPath() instead, it returns the absolute filesystem path for the given relative path from the current context root.
    File file = new File(servletContext.getRealPath("/"), "xyz.xml");

  • Dreamweaver templates and relative file paths

    It seems on occasion - especially with the embed tag - a
    relative file path in the dwt file becomes an absolute file path in
    the file it makes. The worst thing is that it doesnt happen
    consistently, Ive created 4 files from a template and now all of a
    sudden when i make a new one the path doesnt update. I'm also using
    coldfusion with these tags which could be the problem. Either way I
    dont want to have to reedit every page with notepad. Heres my code
    template code:
    <object
    classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="
    http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0"
    width="730" height="295" align="middle">
    <param name="allowScriptAccess" value="sameDomain" />
    <cfoutput>#IEcat#</cfoutput>
    <param name="quality" value="high" />
    <param name="bgcolor" value="#ffffff" />
    <cfoutput><embed
    src="../new/flash/navigation6a.swf#cat#" quality="high"
    bgcolor="##ffffff" width="730" height="295" align="middle"
    allowscriptaccess="sameDomain" type="application/x-shockwave-flash"
    pluginspage="
    http://www.macromedia.com/go/getflashplayer"
    /> </cfoutput>
    </object>
    code rendered from template:
    <object
    classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="
    http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0"
    width="730" height="295" align="middle">
    <param name="allowScriptAccess" value="sameDomain" />
    <cfoutput>#IEcat#</cfoutput>
    <param name="quality" value="high" />
    <param name="bgcolor" value="#ffffff" />
    <cfoutput><embed
    src="file:///D|/KMI%20websites/centerplate.ca/site/new/flash/navigation6a.swf#cat#"
    quality="high" bgcolor="##ffffff" width="730" height="295"
    align="middle" allowscriptaccess="sameDomain"
    type="application/x-shockwave-flash" pluginspage="
    http://www.macromedia.com/go/getflashplayer"
    /> </cfoutput>
    </object>
    on a side note, in the object param tag when using the output
    tags inside the quotation marks of the value it turns all non
    alphanumeric characters into ascii
    any help on either problem will be much appreciated

    Whe you spawn the child page from the template, you will see
    ALL of the
    links look like that until you save the page. Once you save
    it, DW knows
    how to adjust the links so that they remain relative to the
    saved document.
    Murray --- ICQ 71997575
    Adobe Community Expert
    (If you *MUST* email me, don't LAUGH when you do so!)
    ==================
    http://www.dreamweavermx-templates.com
    - Template Triage!
    http://www.projectseven.com/go
    - DW FAQs, Tutorials & Resources
    http://www.dwfaq.com - DW FAQs,
    Tutorials & Resources
    http://www.macromedia.com/support/search/
    - Macromedia (MM) Technotes
    ==================
    "ogre11" <[email protected]> wrote in
    message
    news:[email protected]...
    > It seems on occasion - especially with the embed tag - a
    relative file
    > path in
    > the dwt file becomes an absolute file path in the file
    it makes. The
    > worst
    > thing is that it doesnt happen consistently, Ive created
    4 files from a
    > template and now all of a sudden when i make a new one
    the path doesnt
    > update.
    > I'm also using coldfusion with these tags which could be
    the problem.
    > Either
    > way I dont want to have to reedit every page with
    notepad. Heres my code
    >
    > template code:
    >
    > <object
    classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
    > codebase="
    http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#
    > version=7,0,0,0" width="730" height="295"
    align="middle">
    > <param name="allowScriptAccess" value="sameDomain"
    />
    > <cfoutput>#IEcat#</cfoutput>
    > <param name="quality" value="high" />
    > <param name="bgcolor" value="#ffffff" />
    > <cfoutput><embed
    src="../new/flash/navigation6a.swf#cat#"
    > quality="high"
    > bgcolor="##ffffff" width="730" height="295"
    align="middle"
    > allowscriptaccess="sameDomain"
    type="application/x-shockwave-flash"
    > pluginspage="
    http://www.macromedia.com/go/getflashplayer"
    /> </cfoutput>
    > </object>
    >
    > code rendered from template:
    >
    > <object
    classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
    > codebase="
    http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#
    > version=7,0,0,0" width="730" height="295"
    align="middle">
    > <param name="allowScriptAccess" value="sameDomain"
    />
    > <cfoutput>#IEcat#</cfoutput>
    > <param name="quality" value="high" />
    > <param name="bgcolor" value="#ffffff" />
    > <cfoutput><embed
    >
    src="file:///D|/KMI%20websites/centerplate.ca/site/new/flash/navigation6a.swf#ca
    > t#" quality="high" bgcolor="##ffffff" width="730"
    height="295"
    > align="middle"
    > allowscriptaccess="sameDomain"
    type="application/x-shockwave-flash"
    > pluginspage="
    http://www.macromedia.com/go/getflashplayer"
    /> </cfoutput>
    > </object>
    >
    > on a side note, in the object param tag when using the
    output tags inside
    > the
    > quotation marks of the value it turns all non
    alphanumeric characters into
    > ascii
    >
    > any help on either problem will be much appreciated
    >

  • CS2/CS3/CS4: Cannot get file path in Unicode of the current document on Windows

    Hi All,
    In my automation plugin I need to have full absolute path of the opened document with any possible non-English letters. Using SDK examples Listener and Getter that come with Photoshop SDK the full absolute path which I obtain is in the default ANSI code page (CP_ACP) and I can convert it to Unicode using MultiByteToWideChar() API. However this works well when I have corresponding to document name language set in the "Control Panel -> Regional and Language Options -> Advanced -> Select a language to match the language version of the non-Unicode programs you want to use." For example if name of the document has Russian letters and chosen language in "Regional and Language Options" is also Russian the described conversion works well. If I change "Regional and Language Options" to English for example, full path returned by Photoshop SDK API (AliasToFullPath in PIUFile.cpp) for the document with Russian letters will contain "????????.psd" symbols.
    So I need to have an ability to get absolute file path in Unicode. Is it possible in Photoshop CS2/CS3/CS4 for Windows? I have searched forum and SDK but could not find info on it.
    Is it possible to have native HANDLE of the opened file to get file info using Windows API?
    Please advice.
    Below given slightly modified code from Photoshop CS3 which I use to get absolute file pat of the opened document.
    Thanks and regards,
    Sergey
    std::string outFilePath;
    int32 theID = 0;
    SPErr error = kSPNoError;
    error = PIUGetInfo(classDocument, keyDocumentID, &theID, NULL);
    if (error == kSPNoError)
    Handle theFileHandle = NULL;
    error = PIUGetInfoByID(theID, classDocument, keyFileReference, &theFileHandle, NULL);
    if (error == kSPNoError)
    int32 length = sPSHandle->GetSize(theFileHandle);
    Boolean oldLock = FALSE;
    Ptr pointer = NULL;
    sPSHandle->SetLock(theFileHandle, true, &pointer, &oldLock);
    if (pointer != NULL)
    outFilePath = (char*)pointer;
    sPSHandle->SetLock(theFileHandle, oldLock, &pointer, &oldLock);

    Hi All,
    Does anybody know, whether it is possible to get Unicode file path of the current document in Photoshop via Photoshop SDK API or without them?
    Thanks,
    Serhiy

  • Customizing AM Images & Facing Problem in Update & Deploy War files

    Hey Guys!
    This is Yash Bansal from Gurgaon, India. i am new to access manager. i am now customizing it and facing problem in customizing.
    I have customized images which is present in directory path:
    opt/SUNWam/web-src/services/images/
    and updated services.war file which is present in directory path:
    opt/SUNWam/war/
    with command
    jar -uvf services.war /opt/SUNWam/web-src/services/images/login-backimage.jpg
    then deployed configuration from the web server 7.0 admin console.
    after that when i open the url
    http://<hostname>/amserver/console
    then Page Not Found error comes in the browser.
    Just wanted to ask you guys am i doing the steps right. please help if someone know how to update and deploy war file on Sun Web server 7.0.
    Thanks & Regards,
    Yash Bansal

    Hi!
    Deploying the configuration does not (re)deploy the application. Webserver stores a copy of the deployed application and all configurations in the admin instance. When you change anything in the webserver console it is first written there and only applied to the productive instance when you deploy configuration.
    When you add images, jsps or something else to /opt/SUNWam/... and want it redeployed you have to use amconfig command. in /opt/SUNWam/bin there is a file called amsamplesilent. You have to fill the values in this file and then use
    ./amconfig -s amsamplesilent
    I believe for a redeploy you have to set DEPLOY_LEVEL to 21, not sure here, check documentation.
    I personally usually do not redeploy for images and such, I simply copy them directly the deployed location.
    Why http://.../amserver/console does not work anymore, I have no idea. But at least after a redeploy it should be there again.
    hth Chris

  • Importing WAR file into Web Module Project

    Hi,
    I am brand new to SAP and i'm trying to help out with a proof of concept for our SAP rollout.  I am trying to import a J2EE application that currently runs on WebSphere 5.1 and was developed using WSAD.  I found a blog on the SAP site and it gave a simple run down of how to Migrate from WebSphere application server to SAP Application Server.
    Here is the link: /people/community.user/blog/2007/03/06/migrating-application-from-websphere-application-server-to-sap-was
    The steps seem simple enough yet I am having issues trying to import my WAR file into my Web Module Project in Netweaver.
    Step 4 gives the following instructions: Create a WEB Module Project and import the WAR file.
    Unfortunately, they do not give more detail besides Import the WAR file.  When I try importing my WAR file, it adds the WAR file in my Web Content folder.  I was expecting it to extract all my java classes and my jsp files but this is not the case.  To do this, I right clicked on my Web Module Project while in the J2EE Explorer view and selected import file and selected my WAR.  I'm assuming this is not correct.
    Any help would be appreciated.
    Thanks,
    Phil

    Hi Phil!
    You don't need to create previously a web module to import the war then.
    I'm assuming you're using NWDS (Netweaver Developer Studio). Try this. In NWDS: File -> Import... ->
    then, select "WAR file". After that, you need to inform the path of you WAR file and automatically it will fill in the name of your project, that you can change if you desire. After that, click in Finish and it's all.

Maybe you are looking for

  • Problem displaying PDF in Firefox 4 browser

    Since installing Firefox, I cannot download a PDF file larger than 5MB and get it to display in the browser. A file of 4.9MB works OK. If I disable the Adobe Reader plug-in, I can download the larger file and it will display in Adobe. Same issue with

  • CLOB data type

    Problem in firing 'IF' statement which is checking whether a clob variable is NULL in a database trigger, which fires when a record is inserted thru the forms. The NOT NULL is working fine and updating but the NULL condition is not working, the trigg

  • IOCTL's from a static library linked to KMDF driver

    Hi, Im trying to build a static library that can be used across multiple KMDF drivers. The library needs to send IOCTL's to another driver to access required functionality.  The library does not have access to the Wdf device object/objects of the KMD

  • PE3 installs on Vista 64; nothing runs beyond splash screen

    I'm trying to install Premiere Elements 3.0 on my new Vista 64-bit machine. Nothing happens once the splash screen disappears. Here are the details: - The PC has 4G RAM, full system updates applied, etc. - I installed, in order: - Quicktime - PE3 - P

  • Collaboration Iview

    Hi All, This is regarding an iview to directly access a collaboration room. Our requirement is to have a workset that takes the users directly to their collab room. We do not want to use the 'Room Directory' and then let users click on a room for acc