Specify a file location in web app structure?

I wish to store several small properties in a file for my web app, but how to control where they go? for instance (used in a class called from a jsp):
FileOutputStream out = new FileOutputStream("tempFile.prop");
out.println("test out");
out.close();where does tempFile.prop go? Right now it appears to go into the root directory of the web app, but I would like to be able to dump it into web-inf, or in some other folder in my application.
How do I specify a relative file location in the web app structure?
On most runs of the app, the file is stored in the root folder of my app (the context?)
Can I code relative paths from there, and how do i gaurantee where the files will go?
I have tried several different things, and most of the time the behavior is as reported, but on a number of occaisions, the files go into tomcat/bin. WHAT? WHY? anyway, if there are any tried and true rules on this, let me know.
Thank you

Check out the File class, which can check the directory and file's existance (and other properties). I would simply create servlet that checks/writes to a file in which you can actually specify the path to the file, whether absolute (c:\\..\\..\\kf.prop) or relative (using servlet context to get to the webapp folder and then to various directories below that).
Good luck

Similar Messages

  • HT1923 I get a message-error opening installationlog file. Verify that the specified lof file location exists and is writeable-when I try to uninstall iTunes and other components

    I get a message-error opening installationlog file. Verify that the specified lof file location exists and is writeable-when I try to uninstall iTunes and other components. How can I uninstall and reinstall iTunes?

    Hey jemerritt,
    Thanks for the question. I understand you are experiencing issues with iTunes for Windows. The following resources may help to resolve your issue:
    iTunes 11.1.4 for Windows: Unable to install or open
    http://support.apple.com/kb/TS5376
    Issues installing iTunes or QuickTime for Windows
    http://support.apple.com/kb/HT1926
    Thanks,
    Matt M.

  • [iPhone] Location-aware web app

    I've been tapped to create a web app formatted for use on an iPhone that will display results depending on the user's current location. Since this is a web app, not an internal one, is there a way I can get a user's location sent to a web app (query string is fine) without creating an internal app?
    For instance, I'd like to make web bookmark on the home screen that would go to
    http://www.whatever.com/lat=xxx.xxxxx&long=yyy.yyyyy
    where x and y are the lat and long of the user's current location. Obviously, x and y will change depending on where the user is. Thanks in advance

    I am not aware of any JavaScript hacks or any other API which would allow a Mobile Safari page to access Core Location features. This would result into kind of a privacy/security issue.
    Why don't you create a very basic native SDK based app that does nothing more than calling your URL and encoding latitude and longitude into the GET/POST request?
    All other web sites that display location based content (see Locly and others) do it exactly like that and it works like a charm.

  • Best way to transfer file between two web apps

    I'm looking for some architectural suggestions. Seems like a simple problem, but I'm really struggling.
    -- Problem:
    We have two web servers, both running apps in JBoss. I need to pass a file of roughly 20MB from one server to the other, and get the other server to process it as soon as it receives it.
    -- Details:
    Seems simple enough... My plan was to write a web service to pass it. Our company is all onboard the SOA train. I wrote a service that encoded the file as a byte[] and passed it. Works amazing for small files, but throws an Axis OutOfMemory error when trying to base64 encode the file. I then looked at using attachments for web services, but dismissed that. It creates malformed XML since it treats the service as a multipart MIME message wraps the webservice inside. It quickly became messy and I couldn't get it working. Seemed to defeat the purpose of an XML service too.
    I've considered just doing a HTTP POST of the file to the other server, but that's poorly documented and a bit of a hack way to do it. I also considered just dropping the file in a web accessible folder, then using a web service to pass a URL and get the other server to retrieve it via HTTP. Again, not a very nice solution.
    Anyone have any suggestions? Thanks.

    Kimos2 wrote:
    I don't have access to run/configure services on these machines, so FTP is out. It has to be JVM to JVM. Even if I did, I'd have to worry about triggering JBoss to process the file right away after it had been dropped there. I know i could poll the directory or send a message to trigger the process, there'd be synchronization issues etc to work through and seems to introduce unneeded complication.Yes, I agree with that. Having been through the polling directories and grabbing partially uploaded files scenario ad nauseam. It's much worse with large files too.
    Barring any suggestions I haven't thought of, I'll probably end up settling on the HTTP POST solution. My problem is that it's providing a service without a specification and is not self-describing. No WSDL file to pass to clients that plan on using it. I would do HTTP POST as well. I didn't understand the part about "without a specification". You do have a specification, don't you? Wasn't this it: "I need to pass a file of roughly 20MB from one server to the other, and get the other server to process it as soon as it receives it." Informal, yes, but I don't have a problem with that. Post it to a URL on the receiving server and set up the receiving server to do whatever it's supposed to do with the file.

  • Using JNDI to access config file located outsite j2ee app

    Hi I'm wanting to store a config file for my J2ee app, somewhere on a tomcat server possibly inside the
    conf/ directory so that I can update this config file without having to redeploy the j2ee app every time a change is made.
    I've been told I can use JNDI to access this file, but I can't seem to find any examples or documentation on how I can do this.
    I'm new to JNDI and would appreciate any help, or suggestions.
    Thanks,
    Tim
    EDIT:
    So far I can access the file with this code:
    Hashtable env = new Hashtable();
              env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.fscontext.RefFSContextFactory");
              try {
                   Context ctx = new InitialContext(prop);
                   // look up context for name
                   //env.put(Context.PROVIDER_URL, "file:C:\\confluence\\confluence-2.5.1-std\\conf");
                   File f = (File)ctx.lookup("/confluence/confluence-2.5.1-std/conf/test.txt");My new problems are:
    1. The commented line env.put(Context.PROVIDER_URL, "file:C:\\confluence\\confluence-2.5.1-std\\conf"); it says in examples that this should set the dir to look in to the conf dir but if i change the lookup value to just test.txt it cannot find it.
    2. Can I somehow set the context to look into the conf directory of Tomcat without hard coding the path, as the path could change or be different on different machines??
    Edited by: Timothyja on Jan 15, 2008 7:00 PM

    Hi Kiran,
    Looking at the code you sent and the error, it looks like you should be casting the ds object to a javax.sql.DataSource object not a weblogic.jdbc.common.internal.RmiDataSource object.
    You may find some useful info at the following URL:
    http://edocs.bea.com/wls/docs81/jdbc/rmidriver.html#1026007

  • Wsdl file location in the apps r12 (service created by using the jdevloper)

    Hi,
    this is issue is related to apps R12.
    I want to edit the WSDL file of the smsservice devloped through JDevloper.
    as it is working fine in Prod and I want to test it in test envirnment to how from where I will get wsdl file of the service so that I can change the url of the test in the wsdl file.
    Please suggest.
    harry

    Any suggestions. I also would like to knoe the location of wsdl file.

  • Specifying a file location

    Hi I have the following 3 lines of code
    1. in = new FileInputStream("xanadu.txt");
    2. out = new FileOutputStream("outagain.txt");
    3. int c;
    I want to specify where the files xanadu.txt , outagain.txt are located. So i want to use the full path.
    If i place the .txt files in C:\ directory how the syntaxt of lines 2 & 3 going to change?
    Regards

    It would change like this
            in = new FileInputStream("c:\\xanadu.txt");
    out = new FileOutputStream("c:\\outagain.txt");Remember you always need to escape your slashes, and that an absolute path is usually file-system-dependent. It's not strictly necessary to make a File object first.

  • Reading file from Java Web App?

    My application has a custom configuration file that I want to read at runtime.
    What directory should I put the file in and how should my code locate the file at runtime?
    Obviously, I don't want to hardcode paths.
    Is there an easy way to find the file at runtime if it's in my classpath root?
    (sorry for the repetition, I posted a vartion of this question at the end of another thread.)

    Just read your post in the other thread ... another why of doing this could be to set your own environment variable and then use it within your app.
    ie. in a DOS window (or better still, use the Environment Variables option within the Properties of My Computer).
    c:\>set myAppCfgFile = c:\myapp\myconfig.inithen in Java.
    String pathAndFilename = System.getenv("myAppCfgFile"); // note, environment variables are not case sensitive (or shouldn't be).

  • Uploading and downloading files from a web app (Urgent!!)

    Hi everyone:
    I'm developing an application in PL/SQL to upload and download files from an HTML webpage. I congured the document table and the parameters necessary in the DAD of my application.
    when I upload the file using my webpage that file info is automatically uploaded to the doc table. This is as far as I have gotten.
    I need to do the following:
    - Place the uploaded file into a column in another table in my database as part of a text message (think of it as an email message), and delete the file from the doc table (as this is thought to be a temp table that holds the file when uploaded from my webpage)
    - Retreive the file so that it can be downloaded from another web page.
    The file can be a PDF, WORD DOC, etc...
    I now that I can do this with InterMedia but I haven't figured out how :(
    Can anyone please point me to an example or some documentation that can guide me through the process.
    DB VERSION: 8.1.7
    IAS VERSION: 1.0.2.2
    Thanks,
    Carlos Abarca

    The idea was for you to look at the code and get an idea of how to access the BLOB in the document table. IF you look at the procedure
    insert_new_photo( new_description IN VARCHAR2,
    new_location IN VARCHAR,
    new_photo IN VARCHAR2 )
    It shows how to access the blob that is stored in the document table. You can then copy this blob to your own table using the DBMS_LOB package.
    Hope this helps,
    Larry

  • All excel attachment files in Outlook web app (email) are renamed "attachment.ashx", losing their original file names. Why? And how do I fix this?

    While the email displays the attachment with the "original file name.xls", when I click and download, it is called "attachment.ashx", and I lose all the original downloaded file names. This started happening about 3 weeks ago after a Firefox update. Suggestions for a fix?

    Outlook Web Access sends illegal Content-Disposition headers and this is no longer allowed in Firefox 8. The server needs to be fixed.
    See:
    * https://support.mozilla.com/en-US/questions/894442
    * https://support.mozilla.com/en-US/questions/895024

  • Trying to install Photoshop Elements 12 from a DVD. I keep getting an error message that says "Error opening installation log file.  Verify that the specified log file location exists and is writable."  Have tried the solutions suggested on line but get t

    Have tried turning explorer of and on again and other recommended solutions but nothing seems to work.  Any suggestions?

    David,
    Can you please try Right-Click Setup.exe  > Run As Administrator
    and see if it helps.
    Thanks,
    Anwesha

  • Programmatically specify file location within ear file

    Hi guys,
    I am deploying an ear file under weblogic 6.1 and in part of the code I need to parse an xml file however, I can't figure out how to specify the path to the file. Whatever I try I always get an exception telling me the file cannot be found. The file itself resides within WEB-INF in the applications jar file which itself resides within the ear.
    I don't know how to specify the files location.
    Please help!
    Simon.

    Hi Simon,
    I'm not sure if this will help - but I have had similar problems and am happy to share my experiences with you and hope they help you. (my test were done on JRun 3.0 - but am sure the behavior under weblogic is similar)
    I am not sure what method you are using for accessing your xml file and what the package structure of you apps is but I assume that you are either doing a
    <code>
    String fileName = "myFile.xml";
    File f = new File(fileName);
    or
    URL u = this.getClass().getResource(fileName);
    </code>
    I found problems with both these methods when deploying as a web app. The first method places the file in
    <code> {JRunPath}\servers\default </code>
    directory (which it should as the spec by default creates the file in the users default directory)
    and the second creates a URL that does not correctly map to the location (see my post http://forum.java.sun.com/thread.jsp?forum=136&thread=184500)
    neither of these is suitable for deploying a webapp. The only way to locate the resource seems to be to use either
    <code>
    fileName = ServletContext.getRealPath(fileName);
    or
    URL url = ServletContext.getResource(fileName);
    </code>
    This does leave open this issue on how to pass the servlet context down to the specific class within your application that loads the xml - the uglier option is to pass the servlet context object right down to the class that loads the resource - the other option is to use some kind of a static initializer to make the servletcontext object globally available
    hope this helps

  • Cannot open file in Onenote client from within OneNote Web App

    I am facing a peculiar problem with One note.
    Environment: - SP2013 Enterprise with separate Office Web Apps server
    I can view/edit onenote files on OneNote web app without any issue but when I click "Open in OneNote" button, I get the error that "onenote cannot open the specified location..."
    Other office documents like word and excel work fine, only onenote has this issue.
    Any help is much appreciated

    Thank you for the update.
    We may try to use the Network Monitor tool to capture the network traffic for bothe problematic site and working site when reproducing this issue, and then read the traffic to find out the differences between them. To capture the traffic, start capturing
    first, then click the “Open in OneNote” button.
    Download Microsoft Network Monitor tool:
    http://www.microsoft.com/en-us/download/details.aspx?id=4865
    If you cannot find the differences, you can send the capture files to us via
    [email protected]
    and we will analyse them for you.
    Regards,
    Steve Fan
    Forum Support
    Come back and mark the replies as answers if they help and unmark them if they provide no help.
    If you have any feedback on our support, please click
    here

  • Invalid element 'welcome-file-list' in content of 'web-app',

    HI, folks.
    I recently used struts to develop a simple web applicaiton, and whenever I tried to use tag libs
    such as /WEB-INF/struts-html.tld
    /WEB-INF/struts-html.tld and
    tried to compile it, it gives out compile error such as:
    Error(52,21): Invalid element 'welcome-file-list' in content of 'web-app', expected elements '[taglib, resource-env-ref, resource-ref, security-constraint, login-config, security-role, env-entry, ejb-ref, ejb-local-ref]'.
    if I remove the above tag libs, the jsp file compiles
    without any problem.
    Are you guys familiar with these problems?
    please let me know if I'm doing anything foolish.
    Thanks!

    Unless some other elements tag are not close correctly this error does not make sense. Can you cut and paste your web.xml?
    It should look something like:
    <?xml version = '1.0' encoding = 'windows-1252'?>
    <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
    <web-app>
    <welcome-file-list>
      <welcome-file>/untitled1.jsp</welcome-file>
    </welcome-file-list>
    <taglib>
      <taglib-uri>/WEB-INF/struts-html.tld</taglib-uri>
      <taglib-location>/WEB-INF/struts-html.tld</taglib-location>
    </taglib>
    </web-app>Charles.

  • In ver 8xx download one file don't work with Outlook Web App

    If I download file from Outlook Web App (for example name.doc) in ver 8 and 8.0.1 in Save File firefox say You have chosen to open attachment.ashx which i a ashx file from https://.........
    In prev versions all was ok.

    Outlook Web Access sends an illegal Content-Dispositon header to Firefox. This is no longer allowed in Firefox 8. Firefox 9 will have a workaround for this so that Microsoft has time to fix their software.<br>
    See http://support.mozilla.com/nl/questions/895024<br>
    https://support.mozilla.com/en-US/search?q=attachement.ashx<br>
    Bug 704989 - add workaround for broken Outlook Web App (OWA) attachment handling <br>

Maybe you are looking for