This topic has no replies.
I have this code below that outputs the pdf file from a JSP using a servlet. The problem is if filename has period (.) (Ex. AAA.BBB.CCC.PDF) within it I gey a socket write error, and cant output the pdf file. Can anyone help me with this.
Thank You
JSP Code:
document.write("<object classid=\"clsid:CA8A9780-280D-11CF-A24D-444553540000\" id=\"BravaDTXView1\" width=\"100%\" height=\"100%\"> ");
document.write(" <param name=\"src\" value=\"/TifPdfDisplay?filepath=<%=sFilepath>\"> ");
document.write("</object>");
Servlet Code:
public void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
request.setCharacterEncoding(Constants.GlobalVariable.CHARSET);
String sFilePath= (String) request.getParameter("filepath");
// Read in PDF test file
File l_file = new File(sFilePath);
FileInputStream in = new FileInputStream(l_file);
int length = in.available();
byte[] pdfbytes = new byte[length];
in.read(pdfbytes);
in.close();
// Send response
response.setContentType("application/pdf");
response.setContentLength(pdfbytes.length);
ServletOutputStream ouputStream = response.getOutputStream();
ouputStream.write(pdfbytes, 0, pdfbytes.length);
ouputStream.flush();
ouputStream.close();
}
This topic has no replies.
Back to Forum
Read the Developer Forums Code of Conduct
Email this Topic
Edit this Topic
Site Upgrade
Forums 7.1.8 was deployed Oct 26th. The release consists of minor fixes & a few enhancements.
Forums Statistics
Users Online : 25 Guests : 132
About Sun forums
Oracle Forums is a large collection of user generated
discussions. It is here to help you ask questions, find answers, and
participate in discussions.
Check out our guide on Getting
started with Oracle Forums for a full walkthrough of how to best
leverage the benefits of this community.