aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes need to create a link so a file on the network opens Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "need to create a link so a file on the network opens" Watch "need to create a link so a file on the network opens" New topic
Author

need to create a link so a file on the network opens

William Peck
Ranch Hand

Joined: Dec 18, 2009
Posts: 54
I need to build a link in a JSP page that looks (in effect) like this
CDR Load

So it's pulling up a file from the corporate file system

The destination and the link text are both data returned from Oracle.

I tried it like this and the URL is formed ok, looks like a link, but when I click it nothing happens.

<td ><a href="<c:out value="${hist.cdrReportLoc}"/>"><c:out value="${hist.procDescription}"/></td>

With the above command the link looks ok, it comes out as
file:///T:/Operations/IT/IT Shared/Enterprise/EDW/EDW/cdr_reports/ods_cdr_tab_cnt_035_2011_04_26_at_10_33.out

but when I do this is straight HTML, the link opens ok
T drive, April 2011

So something with JSP or JSTL I'm not handling correctly.


Bill in Baltimore
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61433
    
  67

Think about it for a minute:
  • I open your page, on my Mac here in Austin.
  • The page opens in Safari on my Mac.
  • Now I click on the link.
  • Safari sees that the link href is file:///T:/Operations/IT/IT Shared/Enterprise/EDW/EDW/cdr_reports/ods_cdr_tab_cnt_035_2011_04_26_at_10_33.out. What is it supposed to do with this URL that only makes sense on your server?


  • Do you still think the link looks ok?


    [Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
    William Peck
    Ranch Hand

    Joined: Dec 18, 2009
    Posts: 54
    I understand what you are saying, but I'm on a corporate intranet, so all users can read the file:///

    if there is a better way to form the URL, I'm all ears.

    But it's not even working because of something I'm not understanding with JSP. With straight HTML, the link works.
    Bear Bibeault
    Author and ninkuma
    Marshal

    Joined: Jan 10, 2002
    Posts: 61433
        
      67

    If a view source on the browser shows the exact same href that works when it's HTML, then it's nothing to do with JSP.

    If they are different, figure out why.
    William Peck
    Ranch Hand

    Joined: Dec 18, 2009
    Posts: 54
    The links are the same in the HTML test and JSP.

    The link opens from the JSP on IE-7, but not on FF 4.0 or Chrome 10.0

    In my neophyte-ness, it seems like it's something to do with JSP that I'm not understanding.
    Bear Bibeault
    Author and ninkuma
    Marshal

    Joined: Jan 10, 2002
    Posts: 61433
        
      67

    Once the HTML reaches the browser, its JSP-ness is gone. Completely.

    So if the href looks fine when you do a View Source, but doesn't work, then there is a problem with the href and it's not really fine. There can be no JSP issue at that point as the browser has no idea where the page came from: JSP, ASP, PHP, cold fusion, or plain HTML.
    William Peck
    Ranch Hand

    Joined: Dec 18, 2009
    Posts: 54
    Ok, makes sense that HTML is HTML, so I will try and determine any differences,.
    William Peck
    Ranch Hand

    Joined: Dec 18, 2009
    Posts: 54
    Well, as I said, the link opens from the JSP on IE-7, but not on FF 4.0 or Chrome 10.0. So I'll post this on another forum.

    thanks
    Bear Bibeault
    Author and ninkuma
    Marshal

    Joined: Jan 10, 2002
    Posts: 61433
        
      67

    Moving this to the HTML forum, as this turns out not to be an HTML issue.

    Logical debugging step: Does the URL work if you just enter it into the browser address bar of the offending browser?

    If not, it means that the URL is in a non-standard format that only IE understands.
    William Peck
    Ranch Hand

    Joined: Dec 18, 2009
    Posts: 54
    yes, it opens straight away when entering from a browser window, good idea.

    but it's got to be something else.

    the JSP is running on Tomcat (on a server that the whole company uses).

    Both links are the same but one works entered directly but the other doesn't work from the JSP rendered page.

    file:///R:/FTP/Highmark/data/test/ods_cdr_tab_cnt_035_2011_04_26_at_10_33.doc - works from browser a test HTML page
    file:///R:/FTP/Highmark/data/test/ods_cdr_tab_cnt_035_2011_04_26_at_10_33.doc - doesn't work from JSP / Tomcat

    Now what ?
    Bear Bibeault
    Author and ninkuma
    Marshal

    Joined: Jan 10, 2002
    Posts: 61433
        
      67

    When you try it in a plan HTML page, are you loading it from a server, or doing "open file"? If the latter, that's not a valid test. The file must be served to test the URLs in real-world conditions.

    If not serving the HTML, try that and report back.
    Bear Bibeault
    Author and ninkuma
    Marshal

    Joined: Jan 10, 2002
    Posts: 61433
        
      67

    Oh, problem revealed (I know there was some weirdness with file:// protocols):

    Mozilla browsers refuse to follow file URLs on a page that it has fetched with the HTTP protocol (i.e. the page's own URL is an http URL).


    Essentially, you can't use the file:// protocol in real pages served via HTTP except in IE.
    Bear Bibeault
    Author and ninkuma
    Marshal

    Joined: Jan 10, 2002
    Posts: 61433
        
      67

    Bear's proposal: write a servlet proxy.
    William Peck
    Ranch Hand

    Joined: Dec 18, 2009
    Posts: 54
    Ok, I will write a servlet proxy . . . if only I knew how . . . I will research and then post later if I can't figure it out.

    Thanks.
    Bear Bibeault
    Author and ninkuma
    Marshal

    Joined: Jan 10, 2002
    Posts: 61433
        
      67

    Easy: all the servlet has to do is open the file and stream it to the response. Be sure to set the appropriate response headers.

    Lots of examples all over the net.
    William Peck
    Ranch Hand

    Joined: Dec 18, 2009
    Posts: 54
    ok, I will do my research tomorrow, thanks.
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: need to create a link so a file on the network opens