The way to do this is to create a link to an action that reads the bytes in from the file and writes the bytes out to the ServletResponse's OutputStream (unless the files are all, for example, text or HTML files that you can place directly within the server's public document root). So you are not linking to the file, but to an Action that knows how to find the file (via a parameter just like you are doing). Perhaps you already have thought of this -- I'm just making sure. If not, please search the list archives for "serving binary content" and/or "download action". This question comes up a lot and you will find lots of useful tips on serving binary files.

As far as the error, I'm not sure, but do you have a global forward that is named "viewfile" in your struts-config.xml? Because that's what the forward attribute to html:link specifies, and that's where it will look for the actual URI . . .

Brij Naald wrote:

Thanks for your answer. If the approach i'm trying now doesn't work, I certainly going to try that one. But it almost works. The action gets called, and it puts the right names in the request.

What I want to do now is to put in the JSP-page links to a page (viewfile) which shows the file in question. So I need links off the form {base}/viewfile?name=filename. Therefore I should use the
<html:link> tag:


When I try the code below I get an exception:

javax.servlet.ServletException: Cannot create rewrite URL: java.net.MalformedURLException: Cannot retrieve ActionForward named viewfile?file=<%= files[i]%>

What can I do about it? (note that the rest of the code works well; if I remove the <html:link> tags, i get a listing of the filenames.

<%
String[] files = (String[])request.getAttribute("filenames");
for (int i = 0; i < files.length; i++){
%>
<html:link forward="viewfile?file=<%= files[i]%>"><%= files[i]%></html:link>
<%
}
%>



Thanks for the hellp!

_________________________________________________________________
Koop geen kat in een zak. Probeer alles 14 dagen bij jou thuis. http://linkstat.neckermann.de/go.mb1?benl_11294



--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to