Hi,

I am trying to get file downloading to work in JSP.  I am
wondering if anyone can help.

Basically, in the first page, I have a javascript function that
calls processfile.jsp.  The file, processfile.jsp, then reads
an InputStream object and converts it to a String object.
Depending on the MIME type, the browser can elect to display
the String object or launch an Open or Save dialog box.  My
problem is that the default file name the dialbox is processfile.xxx
and not the correct value of the file name.  Is there a way that
I can set (as metadata or in the response object) the file name?
Is this handled by the JSP engine?

I know that using cgi bins, all I need in the javascript function is
to append the filename with a slash after the name of the new page.
   newURL = "processfile.jsp/filename";


So my code looks something like this:

In pre-process.jsp:

<script>
function open_file(index)
{
 newURL = "processfile.jsp?index=" + index;
 location.href = newURL;
}
</script>

In processfile.jsp:

<%
int index = convertToInteger(request.getParameter("index"));
Object aFile = xxx.getFile(index);
String mimeType = aFile.getMimeType();
String filename = aFile.getName();
InputStream content = aFile.getContent();

response.setContentType(mimeType);
String conStr = convertToString(content);
out.println(conStr);
%>

Thanks in advance for all of your time and help.

Sunnia

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
FAQs on JSP can be found at:
 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html

Reply via email to