File URL

Hi all!
I'm writing a servlet that writes a text file in the server and send its URL to the clients. The problem is that I don't know how to get the URL! How could I get it?

Maybe this method will help you :
     * Write the content of a URL page to a file system location - depreciated :
* see writeURLContentToFile(URL url, String fileSystemExportLocation)
     * @param request
     * @param url
     * @param fileSystemExportLocation
     * @throws IOException
     public static void writeURLContentToFile(HttpServletRequest request,
                                                  URL url,
                                                  String fileSystemExportLocation) throws IOException {
          String fileType = fileSystemExportLocation.substring(
                    fileSystemExportLocation.lastIndexOf('.')+1,
                    fileSystemExportLocation.length());
logger.debug("Enterring writeURLContentToFile method...");
          HttpURLConnection conn = WebUtils.openURL(request, url);
          BufferedInputStream is = new BufferedInputStream(conn.getInputStream());
          BufferedReader in = new BufferedReader(new InputStreamReader(is));
          FileWriter out = new FileWriter(new File(fileSystemExportLocation));
          String line = "";
          while ((line = in.readLine()) != null) { 
          if (fileType.equals(WebConstants.TEXT_FILE_EXTENSION))
          out.write(WebUtils.mapHtmlToText(line));
          else if (fileType.equals(WebConstants.CSV_FILE_EXTENSION))
          out.write(WebUtils.mapHtmlToCsv(line));
          else
          out.write(line);
          in.close();
          out.close();
     }

Similar Messages

  • Can links from InDesign or InCopy Articles use non-file: URLs?

    I am trying to determine if InDesign CS6 or newer provides any way for links to be to URLs that are not file: URLs. For example, I am using a CMS that provides HTTP access to images. I would like to do something like:
            <Link
              Self="uf3"
              AssetURL="$ID/"
              AssetID="$ID/"
              LinkResourceURI="htp://myrepository.com/resource/binary/myimage.jpg"
           />
    My experiments suggest that this will not work but I'm hoping I've overlooked something.
    Another wrinkle is authentication: for access to the CMS the URLs need to be authenticated, which means InDesign would need to get then authentication information on at least first resolution.
    Is there a way to do this out of the box? If not, what would be required in terms of plugin implementation or library deployment to enable it? Back in CS3 days we were able to use some unsupported libraries to get URL resolution working but it would be nice if it worked out of the box.
    Thanks,
    Eliot

    As far as I know there is nothing new in CS5 (or CS4 for that matter) regarding which styles are retained when exporting frames to InCopy. If you're exporting an individual story (text frame) from ID to IC, the only styles in that ICML file will be the ones used by the text in the story. If there's no text in the story -- you're exporting an empty frame -- then the ICML file won't have any styles.
    It's been this way as long as I can remember.
    What you need to do in InDesign is keep some fake text in the text frame to which you've applied the styles you want the InCopy users to use. Export that, then in InCopy, open it up, delete the text, and the styles will remain. Now you can save it as an actual InCopy template file (ICTD? something like that) from the Save As menu, and when IC users open it, it'll create an untitled, empty copy of the starter InCopy document with all the styles.
    In a non-Woodwing workflow, InCopy users open the actual INDD file and so have access to all the styles, even if the story frame they want to work on in that layout is initially empty. Or, they can import (Load) all the styles from an InDesign doc into their standalone InCopy file from the InCopy Paragraph Style panel menu (Load All Styles).Not sure if you can do the latter w/Woodwing.
    I was pretty sure that Woodwing had a different way of creating InCopy templates, something like InCopy article templates? Not sure.
    AM

  • Reading file from a folder : File dir = new File(URL+aFile_to_add);

    Hi,
    Trying to read files from a dir on my site using a JSP and bean. I've tried nearly every option for the filepath I can think of and it doesn't seem to be finding the file...
    Here's the bit:
    String URL = "images\\wedding_photos\\";
    File dir = new File(URL+aFile_to_add);
    String[] files = dir.list();
    It's working locally, but I obviously had to change the path from c://... to the above.
    The full code is listed below in the addWedding Method
    The method removes the .jpg from the file name and then writes the new file name to a database
    Thanks for any insight.
    Regards
    Jim
    public String addWedding(String aFile_to_add)
    String feedback = "unset in scrubWedding";
    try
    String URL = "images\\wedding_photos\\";
    Class.forName("org.gjt.mm.mysql.Driver");
    java.sql.Connection connection = java.sql.DriverManager.getConnection("jdbc:mysql://localhost/rhwedd2_shop?user=**********&password=*******");
    java.sql.Statement statement = connection.createStatement();
    File dir = new File(URL+aFile_to_add);
    String[] files = dir.list();
    if (files == null)
    feedback = "Sorry, couldn't find the file "+aFile_to_add+"...no files have been added.";
    else
    for (int i=0; i<files.length; i++)
    // Get filename of file or directory
    String filename = files;
    String no_extension;
    //convert string array element into a char array
    char [] charsfilename = filename.toCharArray();
    int newlength = charsfilename.length -4;
    no_extension = String.valueOf(charsfilename,0,newlength);
    filesAdded = filesAdded+", "+no_extension;
    // Show the new file names in stack trace without extension
    //System.out.println("String no_extension " + no_extension );
    statement.executeUpdate("INSERT INTO items VALUES ('"+no_extension+"',5,'"+aFile_to_add+"')");
    // write to table with item_id and weddingid
    feedback = "The following files have been added..."+filesAdded;
    if (statement != null )
    statement.close();
    if ( connection != null )
    connection.close();
    catch(Exception e)
    feedback = "Into the catch";
    e.printStackTrace(System.err) ;
    return feedback;
    }//end addWedding

    String URL = "images\\wedding_photos\\";
    File dir = new File(URL+aFile_to_add); ok, ok, I'll answer...
    1) What gives you the impression that the relative directory "images\\..." exists (or, in other words, what makes you think your current directory is the parent of "images"?

  • Could not load file/URL (file not found) error for JNLP file

    I am completely baffled in trying to figure out why I am getting the following error for some JNLP files but not others:
    Error: could not load file/URL specified: C:\Users\tom\AppData\Local\Temp\javaws2
    java.io.FileNotFoundException: C:\Users\tom\AppData\Local\Temp\javaws2 (The system cannot find the file specified)
    at java.io.FileInputStream.open(Native Method)
    at java.io.FileInputStream.<init>(Unknown Source)
    at java.io.FileInputStream.<init>(Unknown Source)
    at com.sun.javaws.jnl.LaunchDescFactory.buildDescriptor(Unknown Source)
    at com.sun.javaws.Main.launchApp(Unknown Source)
    at com.sun.javaws.Main.continueInSecureThread(Unknown Source)
    at com.sun.javaws.Main$1.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)I have Googled around this forum and elsewhere, and have seen reports that this error is IE-specific, and seems to have something to do with no-cache headers being sent, or with the client browser's cache being full or turned off (which is not my case). I saw the information in the JavaWS FAQ, which recommended turning off security constraints for the JNLP's URI. I tried that, and it didn't help. One of the very baffling things is that I have created several variations of the JNLP file, with varying combinations of jars and property resources, and some combinations always work while other combinations never work. Here's an example:
    <jnlp spec="1.0+" codebase="$$codebase">
       <information>
          <title>demo app</title>
          <description>illustrates weird bug</description>
       </information>
       <resources>
          <j2se version="1.5+"/>
          <jar href="randomFile.jar"/>
          <property name="xxx" value="xxxx"/>
          <property name="swing.metalTheme" value="steel"/>
       </resources>
    </jnlp>The above file always fails with the error shown at the top of this message. However, if I remove either of the two properties, it works fine. And I have created other variations with lots of properties, some of which work. All of these variations are in the same directory in the war file, served by the exact same servlet (a slightly modified version of the jnlp.sample.servlet.JnlpDownloadServlet provided with JDK 1.6.0_3). Assuming that a no-cache header is the problem, what on earth could be causing some JNLP files to always be served with a no-cache header, while others are never served with a no-cache header?
    On a related note, any recommended debugging techniques for seeing what headers are being transmitted? I tried adding a simple check for a "debug=true" parameter in the servlet that causes it to set the content type to "text/plain" instead of JNLP, and that allows me to see (rather than execute) the JNLP XML that's being returned, but it doesn't show me the HTTP headers that are being sent back. If any caching headers are being set, I think it must be being set by the servlet container itself, as it's nothing being set in the servlet code that I can see. So I don't see any way on the server side Java code to output or log the actual HTTP response (or is there?). Any tips in that regard much appreciated.
    Edited by: TomC125468 on Aug 19, 2009 1:35 PM

    Hi Luca-Sanna,
    Thanks for the response. Re browsers, yes, it fails in IE but it succeeds in Firefox. The info on the JavaWS FAQ and other places all seem to indicate that it's an IE issue concerning handling of the cache-control headers.
    I should check in my webserver forum (Sun WebServer 7) to see about logging options. Sniffing on the client side is not possible, as my app is required to use HTTPS exclusively, and unfortunately that also precludes a telnet GET request.

  • Help needed in getting file url

    Hi,
    I work in a project where i need to get the url of the specified file. The code for that is as,
    URL fileURL = Thread.currentThread().getContextClassLoader().getResource();
    The required resource is available in the concerned path. But the file url returns null
    Can you please help in solving the problem.
    Thanks and Regards,
    Mclaren

    Where (text area, label, button) do you want it to do it.
    What do you want it do (browse within the local text area, open the default browser...)
    Text area, use above, JButton (or alike) and open default browser, use ActionListener and JDIC.

  • Problem with file:/// URLs in Safari 2

    I am seeing some confusing behaviour with file:/// URLs: a very simple HTML file with that type of link works as expected (opens the nominated folder) when loading it as a local file from my disk, but when I put it on our web server and retrieve it from there, nothing happens when I click on the file:/// link.
    This is happening under Safari 2.0 on OS X 10.4.2 (cross-tested on a brand-new iMac), but by comparison does not happen under Safari 1.2.4 under OS X 10.3.8 on an old eMac.
    The HTML source as viewed in the browser when loading it each way is identical:
    Go here: link
    Has anyone else seen -- and hopefully resolved -- this?
    Thanks,
    Robert

    I tried clicking on the link and nothing whatsoever happened. So I tried a control click and selected "Open Link in new window" and a new window opened, followed by the Utilities folder opening. I made a test.html file with the link in it, put it on my startup drive and it worked as expected, and ditto for putting it on a second internal drive. I then put it on my iDisk and navigated to it thru its web site address of
    http://homepage.mac.com/francines/testlinks.html
    and discovered that the two other "local" operation links (to launch ScriptEditor) both worked, but the open folder link no longer did, except by using control click and choosing either "Open link in new window" or new tab. A new Safari window or tab opens, then the Utilities folder opens.
    I then tried the page in Firefox, and it didn't work AT ALL, not even with new window or tab. I then tried Mozilla and Netscape. Same deal. The ancient Internet Explorer opened the Utilities folder inside a new browser window rather than the Finder. This might be a clue as to why the link doesn't work as expected, but unfortunately I don't know what it means.
    Francine

  • Error opening file/URL reference by alias and Administrative limit exceeded

    Hello All,
    Problem:
    SMTP Error: 4.5.0 error opening file/URL reference by alias
    and
    Search failed with: netscape.ldap.LDAPException: error result (11); Administrative limit exceeded
    Here is my configuration:
    Windows 2000 server (without Active Directory)
    SP4
    Iplanet Messaging Server 5.2
    Netscape Directory Server 4.16
    IPlanet Messaging Server 5.2 Hotfix 1.09 (built Jan 7 2003)
    We have a group which we use to flash messages to all the users of the mail server. Till last week it was working fine but now I am not able to send messages to this group <group-name>.
    There are around 800 (Eight Hundred) E-mail id the messaging server and the flashed message is supposed to go to all 800 + users.
    Note: I have another group of 300 users and I am able to send an E-mail to this group of 300 users.
    I am using Dynamic Group for Members list.
    The error message I get while trying to send message to this group is
    SMTP Error: 4.5.0 error opening file/URL reference by alias.
    The corresponding error in mail.log file is
    30-Jan-2004 10:55:21.40 41c.7e4.1098 tcp_intranet J 0 <group-name>@domain rfc822; <group-name>@domain domain (localhost [127.0.0.1]) 452 4.5.0 error opening file/URL referenced by alias: <group-name>@domain
    Now when I construct and Test the LDAP URL from Console, the error I get is:
    Search failed with: netscape.ldap.LDAPException: error result (11); Administrative limit exceeded
    I have increased the various limits but I still get the same error when I send mail to that group or do a LDAP Test:
    The deafult and new limits are:
    Sizelimit: Default 2000 New 10000
    Timelimit Default 3600 New 3600
    Lookthroughlimit Default 5000 New 6000
    The corresponding error entry in access log of slapd is:
    30/Jan/2004:12:19:26 +051800] conn=34 op=213 RESULT err=11 tag=101 nentries=0 etime=2 notes=U
    My search for Administrative limit problem and error opening file/URL error in Sun forum and other groups did get some hits but that did not solve my problem.
    I will appreciate any suggestion/comments.
    Thanks and Regards,
    Maneesh Bisht

    Thanks Jay.
    My problem has been fixed.
    Your suggestion was to increase the lookthrough limit. As you would have noticed in my posting that I had increased this limit to 6000 but that did not solve my problem. Today I increased this limit to 10000. And after that I did not get "administrative limit exceeded" error. Also I do not get "error opening file/URL reference by alias" error while sending E-mail to a particular group of 800+ ids.
    Regards,
    Maneesh Bisht

  • File file = new File(URL) - no can do on 1.3?????

    I'm using java v1.3 and when I try to use the constructer File file = new File(URL) I get this error :
    C:\myservlets\TestServlet.java:26: cannot resolve symbol
    symbol : constructor File (java.net.URL)
    location: class java.io.File
         file = new File(path);
    I have looked at the File Class API and there is such a constructer, is it because I am using v1.3, how can I get pass this without installing v1.4?

    I have looked at the File Class API and there is such
    a constructer, is it because I am using v1.3, how can
    I get pass this without installing v1.4?The File(java.net.URL) constructor is not available in 1.3, only in 1.4+...
    Why not use the File (String pathname) constructor?
    bbm1277

  • How to disable security block on intranet file:///// urls?

    I have the latest version of firefox esr and im trying to remove the security blocks which stop it from opening file:///// urls on our intranet website.
    Can anyone tell me how I can disable the feature and get it to open the urls with the relevant program (a folder share windows explorer, and any other document to use the windows default program list).

    Hello,
    Please check if the links below help you in configuring opening of file:// URIs. Please do note that FF does support file:// URIs out of the box, provided the format is set properly
    *[http://superuser.com/a/103030 Open file:// URIs in Firefox]
    *[http://kb.mozillazine.org/Firefox_%3a_Issues_%3a_Links_to_Local_Pages_Don%27t_Work Firefox local pages]
    Hope this helps.

  • WebEngine and File URL

    I cannot get a File URL to work in WebEngine.
    Is there something I need to do to have it recognize File URL's?
    My plan is to have HTML files on the disk that have built in javascript that do the work but call other HTML files and images and what not.
    Julian

    It would be helpful if you could provide us with an example of your code between \\ tags and give us more info.
    Are any exceptions thrown? Are you running your program as an applet or WebStart application? If so, then are your jar files signed? If you are using WebStart, are these tags inside of your jnlp file?:
    <security>
        <all-permissions/>
    </security>

  • File URLs -  do not accept spaces in folder/direcotry name?

    Version of US used is: 1.0.3
    I tried to create a file data source with the following file URL from the Administration Application under the Sources/File tab:
    file://localhost/c:/myDir/New Folder/
    But I got the following error:
    Oracle Ultra Search Error
    Invalid file protocol URL:Folder/
    URL does not begin with file://
    Note: It is not a problem if the folder name does not have a space. E.g. when I renamed "New Folder" to "New_Folder", it was fine.
    My questions: Is that correct that US does not accept file URLs with spaces in the folder/directory names? If so, is it the same with the newer release US 9.0.2?
    Thanks.

    Currently space is used as a delimiter in file seed URL.
    Therefore, user can not crawl files located in directory containing space. This is the case for 9.2, 1.0.3, 9.0.2. You raise a good point, I will evaluate the possibility to remove this restriction in our next release (iAS 9.0.4). If we decide to support this, I will update this question.
    Thanks ! ^_^
    Cindy
    This is the text on Create File Source Step 2:
    ===================================================
    Enter a list of URLs separated by valid delimiters. A valid delimiter can be any one of the following characters: a space, tab, newline or comma.

  • IE launch failure: "Could not load file/URL specified"

    My user is receiving this failure :
    "An error occurred while launching/running the application.
    Category: Invalid Argument error
    Could not load file/URL specified: C:\Documents and Settings\XXX\Local Settings\Temporary Internet
    Files\Content.IE5\GDMVCXEB\StocksMonitor[1].jnlp"
    System Configuration:
    Browser: IE6
    JDK: 1.4.1_02
    OS: Windows2000 Pro SP3
    The launch point is :
    http://www.javapractices.com/apps/stocksmonitor/StocksMonitor.jnlp
    How is this problem rectified?

    Hello,
    same problem here with win xp/sp2.
    Cleaning the cash did not solve my problem.
    I made another acount under windows and installed java and all works good under that account but cant make it work under old acc. work
    Did you got some solution ?
    txs

  • Browser links return "Could not load file/URL specified:"

    The JWS application manager works great, but the links in my browser return an error saying "Could not load file/URL specified:" followed by the path to my temporary internet files. Why does JWS, through my browser, always look to my temporary internet files? I go to the demo page at http://java.sun.com/products/javawebstart/demos.html and any link there returns the same error. The JWS app manager will download and run the demo's just fine, which makes me think there is something wrong with my browser. I am running the following:
    JWS 1.2
    JRE 1.4.1
    IE 5.50
    Any help at all would be greatly appreciated.

    often your browser cache may get corrupted for certain sites/pages... your best bet is to clear your cache and try again... you could also change the settings for how long to keep your cache before re-loading as fresh... :-) it's a shame that this happens, but other than what i have suggested, i don't know any other work-arounds...

  • Can I use WNT UNC for file url crawling

    If I set up a Mapped Drive on Windows NT (e.g., E), I can specify and crawl a file URL that has been entered
    like file:///E:/folder. The problem is that the Mapped Drive is only available while I am logged onto the PC.
    What I need to be able to do is specify a valid UNC in the File URL like
    file:///hostname/folder/subfolder
    I tried the above format, but got an error.
    Does anyone know if and how to specify File URLs using UNC name ?

    File URL crawling does not support UNC in current version.

  • Convert  file url to http url

    Hi, is there a way to convert file url (file:/opt/test/test.pdf) to http url? I have tried so hard and still stuck on it. Please give help. Thanks in advance!

    Hi,
    if you are using strings
    String s;
    s.replaceFirst("file:", "http:");
    http://galileo.spaceports.com/~ibidris/

  • Convert file url to http url in jsp

    Hi, is there a way to convert file url (file:/opt/test/test.pdf) to http url? I have tried so hard and still stuck on it. Please give help. Thanks in advance!

    I found another solution to dispaly my pdf file on browser without storing the pdf file to application real path. My application generated PDF file and stored it to some place like /opt/report/**.pdf. Then define ContentType("application/vnd.fdf"), use java InputStream and outputStream to operater file.
    I deeply appreciate the help from everyone in this forum. I hope my solution could help someone who have the problem like me.
    Here is the code:
    response.setContentType("application/vnd.fdf");
    File f = new File(filename);
    DataInputStream dis = new DataInputStream(new FileInputStrea(filename));
    OutputStream osout = response.getOutputStream() ;
    int data=0;
    long count=f.length();
    try
    while(count !=0)
    data = dis.readByte();
    osout.write(data);
    count--;
    }catch(Exception e)
    System.out.println(e.toString());
    dis.close();
    osout.flush();
    osout.close();

Maybe you are looking for