Hey everyone..
kinda new to jsp, and I am having a bit of trouble getting this code to work. Basically, I am creating an image gallery, and the user needs to be able to download a file by clicking on the link, even if the file is a .jpeg or another file that usually opens in a browser. I am using jsp and xml/xslt.
The way I have been trying to do it, is to have a form on my xslt page that submits back to my index.jsp page. The problem, is that once I hit the download button (to submit the form) on my page, it tries to force the download of the index.jsp file, and not the file I am specifying. Take a look at the code below (i have tested all the variables and they are working:
<%
String hasSubmitted = request.getParameter("hasSubmitted"
if (hasSubmitted != null) {
String filepath = request.getParameter("getPath"
String filename = request.getParameter("getFile"
response.setContentType(
"APPLICATION/X-DOWNLOAD"
response.setHeader("Content-Disposition",
"attachment; filename=\""
+ filename + "\""
java.io.FileInputStream fileInputStream =
new java.io.FileInputStream(filepath
+ filename);
int i;
while ((i=fileInputStream.read()) != -1) {
out.write(i);
}
fileInputStream.close();
out.close();
}
%>
<xtags:style xml="<%=xmlDoc%>" xsl="xsl/sigGallery.xsl"/>
Anyways any help that you guys could give would be MUCH appreciated!
Thanks!
kinda new to jsp, and I am having a bit of trouble getting this code to work. Basically, I am creating an image gallery, and the user needs to be able to download a file by clicking on the link, even if the file is a .jpeg or another file that usually opens in a browser. I am using jsp and xml/xslt.
The way I have been trying to do it, is to have a form on my xslt page that submits back to my index.jsp page. The problem, is that once I hit the download button (to submit the form) on my page, it tries to force the download of the index.jsp file, and not the file I am specifying. Take a look at the code below (i have tested all the variables and they are working:
<%
String hasSubmitted = request.getParameter("hasSubmitted"
if (hasSubmitted != null) {
String filepath = request.getParameter("getPath"
String filename = request.getParameter("getFile"
response.setContentType(
"APPLICATION/X-DOWNLOAD"
response.setHeader("Content-Disposition",
"attachment; filename=\""
+ filename + "\""
java.io.FileInputStream fileInputStream =
new java.io.FileInputStream(filepath
+ filename);
int i;
while ((i=fileInputStream.read()) != -1) {
out.write(i);
}
fileInputStream.close();
out.close();
}
%>
<xtags:style xml="<%=xmlDoc%>" xsl="xsl/sigGallery.xsl"/>
Anyways any help that you guys could give would be MUCH appreciated!
Thanks!