• Post Reply Bookmark Topic Watch Topic
  • New Topic

serve html

 
Chris Pat
Ranch Hand
Posts: 156
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello
I have an object in a session that I am iterating over the members and printing out in a <c:for each>. It works fine except:
One member is a path to a simple html file. I cant create a properly formed href for that file with either c:url or html:link. Either it just gives me the string of the file location or it gives a very malformed url.
Q1: What is the proper syntax to create an href link to the html file that, presently, is on the same system as the server?
Q2. Do I have to do this as a URI object to properly render the link? How? tia.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65516
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please post more information on how you are generating the URL.
[ May 01, 2006: Message edited by: Bear Bibeault ]
 
Chris Pat
Ranch Hand
Posts: 156
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Bear Bibeault:
Please post more information on how you are generating the URL.

[ May 01, 2006: Message edited by: Bear Bibeault ]


Hello
Here is a section of the relevant code:
</table>
<hr>
<br><br>
<table border="1" width="80%">
<tr><th>Title</th><th>Path</th></tr>
<!--pull down the results & the index array and form the table -->

<!--will it pull and convert the Integer wrapper -->
<c:set var="count" value="${sessionScope.count}"/>

<tr>
<c:forEach var="results" items="${sessionScope.results}"varStatus="status">
<c:url value="${results.reviewPathStr}" var="reviewLink">
</c:url>

<td><c ut value="${results.title}"/></td>
<%-- <td><a href="<c ut value="${reviewLink}"/>">TheLink</a></td> --%>
<td><a href="${results.reviewPathStr}">TheLink </a></td>

</tr>
</c:forEach>

the member reviewPathStr, has the string of the path\to\file I cant form a url that will allow it to be served to the browser. As written it just gives the f:\path\to\file. What is the necessary syntax?

Also what should I do if I want this to be able to source and serve this file from another server in another domain? Is that the URI object? tia
 
Eduardo Dela Rosa
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Will this work for you?



Take note of the BACK SLASH before the word "The Link".

HTH.
[ May 01, 2006: Message edited by: Eduardo Dela Rosa ]
 
Paul Clapham
Sheriff
Posts: 21866
36
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The web server won't just serve out any old file that happens to be accessible to users on the machine where the web server is running. It is configured to serve out a certain subset of those files.

Depending on the server's configuration, this subset may be a certain set of directories, or it may be some other set of files. And it's not necessarily the case that the name of the file on the server bears any relation to the URL used to request the file from outside. It all depends on your server's configuration.

So your idea that you can just take a file name from the server and pass it to somebody outside so they can access the file isn't going to work just like that. You have to convert the name of the file to its URL. That may not be possible if the server isn't configured to serve it, and you would have to know the server's setup to be able to do that conversion.
 
Chris Pat
Ranch Hand
Posts: 156
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Eduardo Dela Rosa:
Hi,

Will this work for you?



Take note of the BACK SLASH before the word "The Link".

HTH.

[ May 01, 2006: Message edited by: Eduardo Dela Rosa ]


Hello
It still gives just the path and not the full necessary url to serve to browser. I have tried it with html:link and cant seem to get the syntax correct so it fails parsing. Ideas? Better way? tia
<table>
<tr>
<c:forEach var="results" items="${sessionScope.results}">
<tr>
<td><c: out value="${results.title}"/></td>
<td><a href="<c ut value="${results.reviewPathStr}"/>\">The Link</a></td
</tr>
</c:forEach>
</tr>
</table>
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65516
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is nothing that will convert a file path to an equivalent URL. You'll need to do it by hand. <c:url> will help make sure that the syntax is correct, and help to format parameters, but there is no built-in means to say "here is the file on disk, what's the URL to it?"

Also, please use the UBB code tags when posting code, and be sure to disable smilies.
[ May 02, 2006: Message edited by: Bear Bibeault ]
 
Chris Pat
Ranch Hand
Posts: 156
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello
It still gives just the path and not the full necessary url to serve to browser. I have tried it with html:link and cant seem to get the syntax correct so it fails parsing. Ideas? Better way? tia
<table>
<tr>
<c:forEach var="results" items="${sessionScope.results}">
<tr>
<td><c: out value="${results.title}"/></td>
<td><a href="<c ut value="${results.reviewPathStr}"/>\">The Link</a></td
</tr>
</c:forEach>
</tr>
</table>[/QB]

What is needed is a non-ad hoc way to form file:///f:/path/to/file.
 
Chris Pat
Ranch Hand
Posts: 156
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Bear Bibeault:
There is nothing that will convert a file path to an equivalent URL. You'll need to do it by hand. <c:url> will help make sure that the syntax is correct, and help to format parameters, but there is no built-in means to say "here is the file on disk, what's the URL to it?"

Also, please use the UBB code tags when posting code, and be sure to disable smilies.

[ May 02, 2006: Message edited by: Bear Bibeault ]


Hi
Thanks. Rather than harassing myself with syntax perversity, I will stream the file directly to the browser. It also gives the benefit of obscuring the file location on the server, even though I have a swfw running blocking cifs and other non-http. Is there a better way?
 
Paul Clapham
Sheriff
Posts: 21866
36
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Chris Pat:
... I will stream the file directly to the browser. It also gives the benefit of obscuring the file location on the server, even though I have a swfw running blocking cifs and other non-http. Is there a better way?
If you want your application to serve arbitrary files to the client, then that's an excellent way to do it.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!