Link to home
Start Free TrialLog in
Avatar of Alaska Cowboy
Alaska CowboyFlag for United States of America

asked on

how can I build a URL in JSP page ?

I need to build a link in a JSP page that looks (in effect) like this
<a href="file:///T:/Operations/IT/IT Shared/Enterprise/EDW/EDW/cdr_reports/ods_cdr_tab_cnt_035_2011_04_26_at_10_33.out">CDR Load</a>

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 align="left"><a href="<c:out value="${hist.cdrReportLoc}"/>"><c:out value="${hist.procDescription}"/></a></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
<a href="file:///T:/Operations/IT/IT Shared/Enterprise/EDW/EDW/cdr_reports/ods_cdr_tab_cnt_035_2011_04_26_at_10_33.out">T drive, April 2011</a>

So something with JSP or JSTL I'm not handling correctly.
Avatar of cmalakar
cmalakar
Flag of India image

I believe, as you are trying to access a file on local file system, browser wont allow that access, if the html was served from server.

Because jsp's are served from server, browser is blocking the access to files.

When you open html file from the same machine, where the file being accessed exists, then browser allows because it knows that html was accessed from the same machine, and allows access to local file system.

To get this done through jsp's, you need to send a separate request to your servlet, and download the file.
Avatar of Alaska Cowboy

ASKER

cmalakar,

ok, thanks for the quick reply. So . . . how do I send a separate request to my servlet to download the file ? (I don't know anything about servlets, so if I have one, I wasn't aware of it . . . )
I am having issues between browsers, I got the link to be as accurate as I can get for now. It works on IE-7 but not on FF-4.0 or Chrome 10.0
ASKER CERTIFIED SOLUTION
Avatar of Alaska Cowboy
Alaska Cowboy
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
One way to do it - if the file is located on your corporate file share, then you check if you can make a link in
somewhere under document root of your server which would lead you to
to the location of the file. Then you could have the path to your file
starting with http://  rather tyhan with file:// and this issue about some browsers having possible
limitaions for the file: protocol in the HTML page, downloaded from server, will go away.

unfortunately, I cannot put the documents in the root of my server, it has to be off onto a corporate shared windows directory. Thanks.
You don't need to put the documents there - documents can suit wehere they are;
the only thing you need is to create link to the folder or to upper folder, under which
the documents are sitting
but the documents aren't on a web server, so how do I create the link ? I thought only the file:///... would work.
well usually all servers on one corporate site (at least so it is on all sites in our company)
 are accessed form one another as remote network
folders. That was my assumption that location with the documents is accessible as
network folder from the web server. If that is not the case, then it complicates the situation
it's just a file server, not a web server. I think I will have to write a servlet, if only I knew how.
Is your file server a windows machine?
Or is ait accessible form windows?
If so, it takes just a 15 minutes to set up
a web server on windows machine (Apache)
and then you can use the http: link instead of file:
to your documents
>>Is your file server a windows machine?
yes

but I won't be able to set up apache, this is a corporate environment and everything is locked down.
Well, if you don't have admin privileges on any windows machine, then
you cant do it - true.
see new question