Accessing files external to the WAR

Hello All,
Can any one tell how to access the HTML files which are stored outside to the WAR...
If i prefix the URL with "http://" then normal <a> tag will do the task.
Ex: *SUN* but if i give the complete absolute path like *Help* this is not working. Web server is blocking the access to the documents which are external to the application.
Any suggestions how to do this, I want to open up the HTML file which is residing in the Local file system.
Thanks
Chethan

It's not just external to the application, it looks like it's external to the web server itself... :)
The only thing I can think of is to write a simple servlet that accepts a path or something and returns the file for you. For example:
public class GetFile extends HttpServlet {
     public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
          String path = request.getParameter("path");
          //must be html file only...
          if (path != null && path.indexOf(".") > 0 && path.substring(path.lastIndexOf(".") + 1, path.length()).equalsIgnoreCase("html")) {
               try {
                    File file = new File(path);
                    if (file.exists()) {
                         response.setContentType("text/html");
                         InputStream input = new FileInputStream(file);
                         OutputStream output = response.getOutputStream();
                         byte[] buffer = new byte[1024];
                         while (input.read(buffer) > 0) {
                              output.write(buffer);
                         output.flush();
                         output.close();
                         input.close();
                    else {
                         response.getWriter().println("Unable to find file " + path);
               catch(Exception ex) {
                    StringWriter sw = new StringWriter();
                    PrintWriter pw = new PrintWriter(sw);
                    ex.printStackTrace(pw);
                    response.getWriter().println(sw.toString());
          else {
               response.getWriter().println("No path or invalid path specified");
}This is just a quick hack, you will need to do some tweaking of course. Security would be my biggest concern with something like this.

Similar Messages

  • How To Access a jar file present outside the war file through a jnlp

    Aoa
    I m new to this forum
    I m having problem with my jnlp file
    i want to know is there any way to access a jar file through jnlp.The problem is that my jnlp file is present in the war file
    and i want to know how to acess a jar file through this jnlp.The scenerio is as below
    I m using ear file on jboss.Its hirerchy is as
    -PAN-war.war
    -launch.jnlp
    -PAN-app-client.jar
    my jnlp file is as follows:
    <?xml version="1.0" encoding="UTF-8"?>
    <jnlp spec="1.0+" codebase="http://localhost:8080/" href="PAN/launch.jnlp">
    <information>
    <title>PanEmirates</title>
    <vendor>M Fazal Ur Rehman</vendor>
    <description>PanEmirates</description>
    <description kind="short">PanEmirates</description>
    <homepage href=""/>
    </information>
    <security>
    <all-permissions/>
    </security>
    <resources>
    <j2se version="1.5+"/>
    <jar href="PAN-app-client.jar" download="eager"/>
    <jar href="lib/javafxrt.jar" main="true" download="eager" />
    <jar href="lib/Filters.jar" download="eager"/>
    <jar href="lib/javafx-netbeans-fxuserlib.jar" download="eager"/>
    <jar href="lib/swing-layout-1.0.3.jar" download="eager"/>
    </resources>
    <application-desc main-class="net.java.javafx.FXShell">
    <argument>pan.Main</argument>
    </application-desc>
    </jnlp>
    when i run launch.jnlp file it says unable to download resource http://localhost:8080/PAN/PAN-app-client.jar
    how to access this jar file
    Any help or comment would be highly appreciated
    Regards
    M Fazal Ur Rehman

    Excellent question. I don't see any client-jar in your EAR file structure. So I am assuming you are writing a separate client application which will talk to the ejbs deployed as part of this EAR. You need to do the following:
    Write another EAR file with the following structure:
    ear:
    META-INF/application.xml
    util.jar
    client.jar
    client.jar should have a META-INF/MANIFEST.MF and that should contain Class-Path:util.jar and value for Main-Class attribute.
    Now deploy this new ear to your application server and execute it using Application Client Container that comes with your app server.
    If you don't want to write another EAR file, then bundle th client.jar in your original EAR file.
    Points to note are:
    you have to repackage util.jar again inside this ear file.
    For portability reason, you should use Class-Path manifest entry in client.jar. Refer to http://java.sun.com/j2ee/verified/packaging.html and J2EE platform spec section #8.2.
    Hope this helps,
    Sahoo

  • Access file reside in the solution/package files on azure

    Hi All,
    I have one file in my solution and it will be uploaded along with package file. now one of the task is to validate file uploaded by end-user with file reside in solution. i am keeping uploaded file into the block blob.
    how i can access file reside in solution on cloud ? should i have to kept file in blob or do we have other better option ?
    BR,
    Jonyy

    Hi,
    As I know you can use the Get Package API from Windows Azure Service Management REST API to retrieve files. I think storing files in blob is still a good way:
    http://msdn.microsoft.com/en-us/library/windowsazure/jj154121.aspx
    Thanks,
    QinDian Tang
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

  • How can I access files saved from the browser on my tablet? Doesn't open files?

    I tried to save a document on my tablet but in the downloads place in the browser it wouldn't open. I thought it was OK cause maybe the doc format, but I just tried to save a photo and when I tried to open it, it said "unable to find the default app."
    How can I get the photo on my tablet under pictures or something?  Do I need to download a special app?

    WMA files from libraries usually if not always contain DRM, which makes it impossible.
    (59943)

  • How does one set up remote access via the internet to access files stored on the Time Capsule using airport utility 6.1

    I was just wondering if anyone can provide me with instructions please on how to set up remote access via the internet to the time capsule when away from home?
    I am running OS X Mountain Lion operating system and have Airport Utility 6.1.
    Many thanks to you all for your help.

    I think the instructions should be all in BTMM with iCloud.
    Instructions are all there.
    http://support.apple.com/kb/ht3486

  • XCode Subversion Integration for files external to the project

    Hi,
    I am using the xcode integration to our subversion server. My projects all include files which are shared between projects and stored outside of the projects folders in their own directory. These files are ignored by the xcode source control.
    Is there any way around this? I really don't want to use a third party subversion client as the integration is nice. Is there a way to have shortcuts in my projects to the shared files for example?
    thanks

    thank you for your answer.
    so I'm trying to add a new target now and I have a choice of application or static library, so I chose static library I guess.
    Now I need to know how to build my shared code classes into a lib. How to I do this with xcode?
    Sorry I am very lost with xcode and a mac

  • J2EE, possible to serve clients jsp files that are outside the war file?

    Hi, I was wondering with a J2EE webserver if it was possible to serve clients webpages from jsp files that were outside the client.
    For example say you got your war file in the auto deploy directory on the server and also on the server you got a directory full of jsp files that could be accessed by the webserver just like normal jsp files inside the war file?
    ...I want to do this because I want to be able to add jsp files without rebuilding the war file.
    ....Or is it possible to make the webserver rebuild itself, eg to add or remove files?
    Thanks

    If you are using a S1WS6.1, please try to find a line with WEBAPP in server.xml.
    You should find a line like this.
    <WEBAPP uri="/simple" path="/opt/SUNWwbsvr/https-test/webapps/https-test/simple" enabled="true"/>
    The path parameter shows the directory where the S1WS refers to when the webapplication is executed.
    You can put a jsp into the directory and modify it accordingly.
    Please refer to the following docs. They might help.
    http://docs.sun.com/source/817-6251/pwadeply.html#wp25317
    http://docs.sun.com/source/817-6251/pwadeply.html#wp25890
    thanks,
    -Yuji

  • Where do I put config files for a webapp (war file)?

    To my understanding a war file is supposed to be dropped in. It's isn't intended to be unzipped by the person installing the webapp. Inside my web app I have some xml files I access to get configuration information for how the servlet works. This xml file is intended to be edited by the sysadmin using the webapp. So, it's obvious I can't put my xml file inside my war file otherwise they'd have to unzip it to edit it. So my question is, where do I put it? What is the normal place to put stuff like this for a webapp?
    Example:
    I make a servlet (or jsp/custom tags) that generates an explorer-like directory tree. It reads the tree folders and files from an xml file. So one sysadmin might make a tree that looks like this:
    Fruit
    |-apples
    | |-Gala
    |-oranges
    |-pears
    another sysadmin might make a tree that looks like this:
    Bookstore
    |-Technical Books
    | |- JSP to go
    |-Children's Books
    |-Dr Seuss
    And these are defined in the xml file.
    It's driving me crazy because I want to make my webapp deployable in a war file. Since I have to unzip it right now, the war file is useless.
    Thanks,
    David

    I don't have the answer, but I understand your pain. I was trying to figure this out last year before my company went out of business and made this problem go away.
    The issue is that you want to have a user install your webapp by deploying the war file and configure the app without unzipping the war file. If you can start the webapp first, why not just put the default or empty configuration file somewhere in your webapp director structure and write an administration servlet or JSP to configure it.
    If you must configure the application before it can start up, the following might apply.
    The obvious approach would be to install a properties or xml file separately from the war file and let the user edit that file. The problem is that your servlets and jsps need to be able to find it at run time. This is problematic because the current directory for relative paths seems to vary from one server to another. If I remember correctly, on Windows NT running Tomcat, current directory points to C:\jakarta-tomcat-x.x.x\bin. When running Websphere, it points to C:\WINNT. You can figure this out for the server your user is going to be running and have them put the file in one of those places. But I don't like putting my application files in places like that.
    I can't remember at the moment how it works in other servers, but at least in Tomcat you might put the configuration file in the webapps directory with your war file. Then you could have your servlet do a getServletContext().getRealPath() or something like that and back up the path one level to get to the file.
    At one point I thought it would be nice to put the path to the configuration file in the system environment, but we couldn't find any way in Java to get access to it.
    Will.

  • How can I Write a sine wave in an Access-fil​e?

    I measure a sine wave in LabView 6i. How can I write the datas automatically to an Acces-file, at the same time?
    In my program, I managed it with Execute SQL.vi, I change a number in a SQL statement(String) -> after this I push start and then it writes the statement in the Access-file.
    The problem is, it writes only one data per measurement in the file. How can I write all datas in the Access-file and measure the wave at the same time?
    Thanks for help!
    Attachments:
    getwave.vi ‏49 KB

    On the waveform palette, you will find a "to components" vi that you can break out the array of the waveform. You can then, using a for loop write all of the values from the waveform.
    Better yet, there are examples in the database toolkit manual on pages 3-13 to 3-15 that deal with reading arrays (and even has a waveform example).
    Good luck!

  • Firefox will not allow me to download/display pdf files - wheres's the glitch

    When I click on a pdf file to download it nothing, zero, happens and I have to switch to IE and start all over to get the pdf file - very incomvenient. I use Norton security software which does a few things to me that I don't like but can't find but since it does not interfere with IE I doubt that it's in Norton so must be fire fox. This is a phenomenon that has just arisen in the last few months or so

    Reading PDF files is not Firefox, you can read file external to the browser or with a plugin.
    The Download Window closes instantly the download finishes or may not even open at all bring it back with Ctrl+J
    You are using Foxit Reader instead of Adobe Reader
    make sure it is compatible with Firefox 5 if it is running within Firefox, check their site
    or install Adobe Reader unfortunately it comes with Adobe Air
    whatever that it, and being adobe you have to watch out for
    crapware also being install, McAfee Security Scan, Google Chrome, Adobe Air

  • Best way to access files on Xserve via VPN on iPad?

    Can anyone tell be the best solution for accessing files housed on the companies Apple Xserve remotely via VPN from an iPad? Numbers / Pages etc.
    thanks,
    Rick

    The iPad doesn't natively support file systems such as those on servers, but there are third-party apps that can allow this. FileBrowser is one often mentioned, so you might look into that. VPN will be a separate issue; iOS has a built-in VPN client which works with many VPN systems, but you'll need to see if yours is supported.
    Regards.

  • Mini-Bridge: accessing files

    I am unable to access files/folders via the mini-bridge in PS.  When I click "computer," or my user name, or favorites or anything else in the mini-bridge drop-down menu nothing happens.

    Hi Alec:
    For some reason Adobe won't let me sign back in to post but it appears as
    if the PS mini-bridge is working OK now.  Have no idea why it wasn't
    working as advertised yesterday;  didn't do anything differently today.
    But thanks anyway!
    Kevin

  • Error message when accessing file browser on NMH300

    Hi, i have a problem here. The error message: "The media hub is not responding, please confirm the device is powered on and connected to your network." appears whenever i try to access File Browser on the NMH300 media hub. I tried rebooting the device, resetting the device but to no avail. I still get the error message. I am using the updated firmware 3.18.4. Any idea how to solve this problem?
    Also, i can't seems to rollback the firmware to the 2.17 version even though i have done a reset of the device by pressing the reset button at the back of the device. any help on this?
    Solved!
    Go to Solution.

    Hi,
    Try to press and hold down the reset button at the back of the mediahub for 30 seconds then check if its now reset back to factory defaults.
    I'm curious, when you began having that problem was it at the time when you created a folder under "File Browser" ? Maybe the Linksys article below is the right way of creating folders on the mediahub or just create a folder using the mapped drive.
    Creating and Deleting New Shares Displayed in File Browser 
    Anyway I hope this helps.
    Message Edited by Wilkins377 on 06-17-2009 08:24 AM

  • Is there a way to access my iTunes Library, which is stored on a (PC) External Hard Drive, on a MacBook Air (through an Apricorn Universal Hard Drive Adapter), without transferring the music files off of the external hard drive?

    Is there a way to access my iTunes Library, which is stored on a (PC) External Hard Drive, on a MacBook Air (through an Apricorn Universal Hard Drive Adapter), without transferring the music files off of the external hard drive?
    In other words, because the MacBook Air only has 120 gbs of hard drive space & my old hard drive, from a Lenovo, has 500 gbs of hard drive space (and I have over 120 gbs of music), I’m looking to manage my iTunes music from the external hard drive permanently. Upon attempting to access the iTunes library held on the external hard drive the following message comes up: “The iTunes Library.itl file is locked, on a locked disk, or you do not have write permission for this file”.  Is there a way to get around this?
    Any advice would be greatly appreciated, thanks so much!

    You will have to engage a split library which means you will have to start answering questions on this forum because you will need to learn a lot about how iTunes works in order not that have a big mess at the end of it all.  It also won't be easy when the time comes to relocate it all to different drives.
    You can go to advanced preferences and turn off organize media and copy to items to media folder when adding items to library.  Next read about how to selectively consolidate items to the external drive.
    Sept. 2010, Consolidate selected content - https://discussions.apple.com/thread/2589812 and April 2014, https://discussions.apple.com/message/25414357
    "...selected the new tracks directly in iTunes, Control-clicked on the selection, and saw that now you can consolidate selected items." - http://hints.macworld.com/article.php?story=20090919000326840
    Remember that when you start iTunes without the external drive turned on iTunes will present you with a bunch of broken links.  If you have automatic downloads enabled with iCloud you may have to turn that off to prevent iTunes from repopulating your drive trying to deal with those "missing" tracks.
    If you add tracks in bunches to iTunes and want them to go to different media folders you will need to either add them by holding down the option key while dragging if the desired media folder is not the one set in preferences, or by changing the media folder in preferences.  Changing media folder preferences only applies to new files added, not old ones.
    Okay, I am going to stop typing because you might just reply to me, "Oh, okay, forget it," and I don't need the exercise.
    What are the iTunes library files? - http://support.apple.com/kb/HT1660
    More on iTunes library files and what they do - http://en.wikipedia.org/wiki/ITunes#Media_management
    What are all those iTunes files? - http://www.macworld.com/article/139974/2009/04/itunes_files.html
    Where are my iTunes files located? - http://support.apple.com/kb/ht1391

  • Adobe Bridge shuts down when I try to access files on my external drive. Have been using the drive for months with no problems.

    Adobe Bridge shuts down when I try to access files on my external drive. Have been using the drive for several months with no problems.

    Due to the current unavailability of clairvoyants and mind-readers in the forum, we respectfully request you supply sensible, complete details.
    A lot more information about your hardware and software is needed.
    BOILERPLATE TEXT:
    If you give complete and detailed information about your setup and the issue at hand,
    such as your platform (Mac or Win),
    exact versions of your OS, of Photoshop (not just "CC", but something like CC2014.v.2.2) and of Bridge,
    your settings in Photoshop > Preference > Performance
    the type of file you were working on,
    machine specs, such as total installed RAM, scratch file HDs, total available HD space, video card specs, including total VRAM installed,
    what troubleshooting steps you have taken so far,
    what error message(s) you receive,
    if having issues opening raw files also the exact camera make and model that generated them,
    if you're having printing issues, indicate the exact make and model of your printer, paper size, image dimensions in pixels (so many pixels wide by so many pixels high). if going through a RIP, specify that too.
    a screen shot of your settings or of the image could be very helpful too,
    etc.,
    someone may be able to help you (not necessarily this poster, who is not a Windows user).
    Please read this FAQ for advice on how to ask your questions correctly for quicker and better answers:
    http://forums.adobe.com/thread/419981?tstart=0
    Thanks!

Maybe you are looking for

  • Enter a country for partner 0000002185 with type 'Goods Recipient'

    Hi  everyone, We are using SRM 4.0. For a certain user we are facing the error as: "Enter a country for partner 0000002185 with type 'Goods Recipient'". Kindly help me to resolve this. This error is not occuring for any other user. Regards, Bhakti

  • While condition is taking too much time

    I have a query that returns around 2100 records ( not many ! ) , when I am processing my result set with a while condition , it's taking too much time ( around 30 seconds ). Here is the code public static GroupHierEntity load(Connection con)      thr

  • How can we download a program with screens on local disk

    hi abaper's                   i have to make a report to download a report program which includes some include parograms and screens. just enter the name of a program in selection screen and all includes, screens and program itself will be dowload on

  • Archive Link and SBO

    Hi all, do you know if its possible to use archive link with SAP Buisness One? We want to connect SAP Business One and the document management system from hyperdoc. Thanks for help. Best Regards, Thilo

  • Help with rollover button

    Can someone please tell me how to make these rollover buttons to get URL? The sample flash file can be viewed here http://www.leadstar.com.au/header_page.html and I have attached the code as well. Many Thanks.