i converted download servlet to jsp, and... exception occurred -"You
already got writer."
here is my jsp code..
<%@ page errorPage="error.jsp" %>
<%
String file = request.getParameter("p_file");
byte b[] = new byte[1024];
File file=new File(pp_file);
FileInputStream fin=new FileInputStream(file);
response.setContentType("application/octet-stream");
response.setHeader("Content-Disposition","attachment;filename=" +
pp_file + ";");
ServletOutputStream dataOut = response.getOutputStream(); // maybe, this
line caused problem.
int numRead = fin.read(b);
while (numRead != -1)
{
dataOut.write(b,0,numRead);
numRead=fin.read(b);
}
dataOut.close();
%>
so i tried to use out instead dataOut ..like this..
response.setContentType("application/octet-stream");
response.setHeader("Content-Disposition","attachment;filename=" +
pp_file + ";");
int numRead = fin.read(b);
while (numRead != -1)
{
out.write(b,0,numRead);
numRead=fin.read(b);
}
at this time, content of file just displayed on browser..
how can i solve these problems ? anybody knows ?
===========================================================================
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