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

Similar Messages

  • Background noise removal takes about 3 seconds into each clip in timeline to kick in, so each clip has noise in the first few seconds.  How do you get this to remove noise from the very start of the clip?

    Background noise removal takes about 3 seconds into each clip in timeline to kick in, so each clip has noise in the first few seconds.  How do you get this to remove noise from the very start of the clip?

    insert a 5 second gap in the beginning of the timeline.

  • How do you get your photos, apps etc. from the iCloud after your iPhone 5 has been set up at the AT

    How do you your get your apps, photos, etc,  from iCloud after your iPhone 5 has been set up at the AT&T store?

    http://support.apple.com/kb/HT4859

  • How do you get your webcam device name from the JMF registry?

    Ya, I don't know where the JMF registry is.....is there a list somewhere in the API? Is it somewhere in the Windows registry files after installing JMF? I keep hearing you need to do this when creating a webcam application but never seen it explained anywhere.

    The registry is a file located in the lib directory under the installation of Java Media Framework, called jmf.properties.
    You can edit it with the jmfregistry application provided with JMF, or using the proper classes such as the CaptureDeviceManager.

  • How to find out web-inf path from the physical drive?

    How to find out web-inf path from the physical drive?
    I have some user profiles in web-inf directory.SO I want to know the path from root directory like
    d:/program files/allaire/jrun/appname/web-inf/profiles/username like that.
    Presently I am able to get the path upto the application directory and from that I am concatinationg web-inf/profiles/username .
    But it is giving problems when it is deployed under unix or linux.Because web-inf there it treats as WEB_INF
    SO I want to get the path of web-inf directory with out hard coding.
    Thanku

    String path = application.getRealPath("/WEB-INF/profiles/username");
    Note sure why you need this, but you don't need the real path to read the file - you can get an InputStream using the relative path. See ServletContext getResource() and getResourceAsStream().

  • How do you get word count to print at the end of a document in Pages?

    How do you get word count to print at the end of a document in Pages?

    Pages v5 does not provide a user assignable word count variable. With some AppleScript, and a paste operation from the clipboard, you can have locale punctuated word count in this format: 7,803 — anywhere in your document. The following AppleScript works with Pages '09 v4.3 through Pages v5.5.2 on Yosemite.
    I would suggest that you copy paste the following AppleScript into your [Apple] Script Editor and save it (suggestion) wordcnt.applescript. Then, follow this with an option+Save As… and this time set the File format to Script Bundle, or Application with hidden extension — saved to your Desktop. Provided you have a Pages document open, you are then a double-click from the ability to paste your current word count into Pages.
    Note: If you have Pages word count display enabled, it will automatically count your pasted value as another word which initially may deceive on true word count at the time the script was run.
    AppleScript
    --- copy below this line ---
    property locale : "en_US.UTF-8" -- In Terminal, use the locale command to see yours
    if not ApplicationIsRunning("Pages") then
         display dialog "Pages must be running to use this utility."
         return quit
    end if
    tell application "Pages"
        tell body text of front document
            set wordCnt to count words
            -- Don't want punctuated numbers? Remove the single quote from printf format
            set the clipboard to (do shell script "export LC_ALL=" & locale & "; printf \"%'d\" " & wordCnt)
        end tell
    end tell
    on ApplicationIsRunning(appName)
         tell application "System Events" to set appNameIsRunning to exists (processes where name is appName)
         return appNameIsRunning
    end ApplicationIsRunning

  • How can I get my Aperture library back from the Photos application?

    As stated above, How can I get my Aperture library back from the Photos application?  I'm not a fan of Photos right now and haven't used iPhoto in years, so that wasn't a loss... I didn't realize when I gave Photo's access to my Aperture library, I was going to lose it...
    I want to get it back, any suggestions?
    Thanks again!
    MacTeacherMN

    what means ..."Once you open the Aperture library back into Aperture..."? What do I need to "klick" in order to getting back my old Aperture Project structure....

  • Content Holder How do you get css class to appear in the wysiwyg editor? The only option is "clear class".

    Need an answer to my question: How do you get css class to appear in the wysiwyg editor? The only option is "clear class".

    Liam,
    If it's not supported there, then where can I access the css and do you have any recommendations for a simple app to change the css style?

  • How do you get fontmetrics before displaying something on the screen?

    Let me ask in another way:
    how do you get fontmetrics before displaying something on the screen?
    Edited by: tjacobs01 on Aug 24, 2008 12:03 PM

    and you call getGraphics() it returns nullI learned to not use the getGraphics() method. Check out my posting here where I ask what the getGraphics() method is good for:
    [http://forums.sun.com/thread.jspa?threadID=5233274&messageID=9954741|http://forums.sun.com/thread.jspa?threadID=5233274&messageID=9954741]
    Also, c.getFontMetrics(c.getFont()) will be an NPE because Font is initially null.Maybe I don't understand the question. The following works for me:
    import javax.swing.*;
    public class Test
         public static void main(String args[])
              JTextField textField = new JTextField();
              System.out.println(textField.getFontMetrics(textField.getFont()));
    }Every question should have a SSCCE, so we don't have to guess.

  • The ITS could not connect to the Web Application Server or the R/3 System

    Hi Gurus
    we are in the process of insalling ITS 6.20 (ITS version is 620010318381 ( itsWindowsX64_31-200001681, R/3 4.7 200)
    Actually we installed it for dev/qas server with connectin mode property as "Connect to SAP system Using Applicatin Server"  these are working fine for webgui!
    and the same thing i installed for Production as connection mode property as " Connect to SAP System Using message Server" (hostname/IP, port as 3600 (as instance number is 00) here in the production evnironment we have 2 app servers. The installation got successful but i am not getting the log on screen through the link: http://10.3.3.175:81/scripts/wgate/webgui!
    the error message is :
    Connect Error
    The ITS could not connect to the Web Application Server or the R/3 System
    any help please
    Thanks in advance

    Hello Balaji,
    Check the global.srvc file for errors in the R/3 system information.  The ITS uses the following to connect to your system:
    ~appserver     
    ~routestring     
    ~systemname
    ~systemnumber     
    ~logingroup     
    ~messageserver     
    Which parameters are used depend on how you are connecting (logon group, route string, etc.)
    Edgar

  • ITS could not connect to the Web Application Server or the R/3 System

    ITS 6.20 on a single host on a WinXP test machine, connecting to R3 4.6C.
    The webgui <u>was</u> working, but a test application created in the WebStudio would not work.
    Now it's the other way around, the test application works fine, but the webgui fails with a "The ITS could not connect to the Web Application Server or the R/3 System."
    I have not managed to get ../scripts/wgate/admin/! to work either.
    Is it possible to have both the webgui and WebStudio created applications, working on the same ITS installation?
    If yes, any ideas how?
    Many thanks
    Tim

    Hi Tim,
    You have to check the connection data in the relevant service file e.g.
    ~systemname   
    ~messageserver
    ~logingroup   
    ~appserver    
    ~systemnumber 
    ~routestring  
    ~connectstring
    If the Agate doesn't run you would see an ITS 500 error in the browser.
    Thanks and regards,
    Dieter

  • 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 do i get my podcasts to go from the one i just finished to the next one and how do i sort them from oldest to newest?

    how do i get my podcasts to go from the one i just finished to the next one withouth me having to click on it, and how do i sort them from oldest to newest?

    Not sure if you tried this, but did you hold down both the sleep and home button for 10 seconds? 

  • Recently had to purchase a replacement phone a friend of mine had backed up the data on the lost phone to his Mac laptop how do I get that backed up data from the lost iPhone that's on his Mac laptop to my new replacement phone? Please give step by step

    recently had to purchase a replacement phone a friend of mine had backed up the data on the lost phone to his Mac laptop how do I get that backed up data from the lost iPhone that's on his Mac laptop to my new replacement phone? Please give step by step instructions xoxoxo
    And my iTunes sign in is also screwed up... It is underneath my friends email (the one with my backed up data on his Mac laptop) HOW DO I CHANGE THIS SO THAT I CAN DOWNLOAD APP's again...

    I suspect unless he had some items in iCloud backup then they are gone.  Connecting an iPhone to a different library from that to which it was previously connected will result in the device asking if you want to erase it.

  • HT1711 how do i get my music not purchased from the itunes store onto my iphone? ie music from CDs etc..

    how do i get my music not purchased from the itunes store onto my iphone? ie music from CDs etc..
    I am not able to get this onto my phone. Only music I bought from the itunes store goes to my phone..

    Hello michael.suffoletto
    Check out the article below on manually managing your music by dragging and dropping the music that you want to your iPhone within iTunes.
    Managing content manually on iPhone, iPad, and iPod
    https://support.apple.com/kb/ht1535
    Regards,
    -Norm G.

Maybe you are looking for

  • - Use of ResourceBundle without Locales

    Hello! I'm trying to use a ResourceBundle to store properties that arn't locale-specific - its a sort of look-and-feel type arrangement. The way more specific ResourceBundles inherit properties from more general ones would be really useful, but since

  • Why does support package SAPKH60014 15 & 16 take so long (ECC 6.0)?

    I've been running these three items in a que for 2days.  I don't see any errors in the morning, but maybe because I can't see the errors? I thihk that 14 & 15 have completed and now running on 16 Has anyone implemented and had similar experience? ECC

  • Cloning a Collection with it's projects

    I need to clone a collection with it's projects and do test with it. I follow the instructions referenced in this link (https://msdn.microsoft.com/en-us/library/dd936138.aspx), in the instructions indicates that existing projects must be deleted from

  • Calling a private function when inside another class?

    Can't help it but im curious how classes seem to be able to call private functions inside other classes. I'm mainly thinking about the addEventListener() here. When adding a listening function to a class, that function can be private, and yet it seem

  • Saving pdf attachments received by e mail

    I've only had my tablet 4 weeks, and I'm sure I was able to save pdf attachments when opened with adobe, however I now cann't seem to do this, having re booted etc. Any help out there????????????? Solved! Go to Solution.