java - Getting error while opening PDF in jsp -
i'm getting error while opening pdf in java code :
<%@ page language="java" import="java.util.*, java.io.*, java.lang.*, com.eb.util.propertyutil, javax.portlet.*, com.ub.ac.aeans.*, com.ub.pm.wob,com.eb.ac.aservice, javax.xml.bind.datatypeconverter,com.eb.patientchecklist.portlets.*;" pageencoding="iso-8859-1"%><%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet"%><portlet:defineobjects /> <% response.reset(); response.setcontenttype("application/pdf"); string wobid = resourcerequest.getparameter("wobid"); string filename = resourcerequest.getparameter("filename"); string dir = propertyutil.getpropertyvalue("doc_base") + wobid + "/" + filename; int count = new file(dir).list().length-1; system.out.println("dir hi :" + dir); string root = dir + "/" + count + ".pdf"; file pdffile = new file(root); response.setcontentlength((int) pdffile.length()); system.out.println("path :" + root); fileinputstream reader = new fileinputstream(pdffile); int line; outputstream responseoutputstream = response.getoutputstream(); while ((line = reader.read()) != -1) { responseoutputstream.write(line); system.out.print(line); } %>
when remove line:
response.reset();
the file called in browser it's showing me this:
ava tutorial pdf) /creator (��) /producer (��wkhtmltopdf) /creationdate (d:20130708155338-05'00') >> endobj 3 0 obj << /type /extgstate /sa true /sm 0.02 /ca 1.0 /ca 1.0 /ais false /smask /none>> endobj 4 0 obj [/pattern /devicergb] endobj 8 0 obj [0 /xyz 34.0799999 807.919999 0] endobj 9 0 obj [0 /xyz 39.8400000 636.079999 0] endobj 10 0 obj << /type /annot /subtype /link /rect [34.0799999 772.399999 283.680000 782.959999 ] /border [0 0 0] /a << /type /action /s /uri /uri (http://www.tutorialspoint.com/java/java_pdf_version.htm) >> >> endobj 12 0 obj <> endobj 13 0 obj <> endobj 11 0 obj <> endobj 14 0 obj <<
then when return line:
response.reset();
it's showing me error in console :
getwriter ejppc0175e: cannot writer after getoutputstream has been called
sorry english not good
@admin
ReplyDeletehow to remove error in the java script and syntax script,
Regards,
Deepika Verma