Hi Guys
We run an xpage from a URL like the below which returns a PDF as output. This always works when the URL is NON SSL.:
https://www.domain.org/db.nsf/pdf_active.xsp?documentid=7931FAAF7ED243BF80257F340036FC70
As soon as we try it with the SSL for the domain we get the following error on the console.
"[1154:000A-0B58] 03/02/2016 15:40:36 HTTP JVM: com.ibm.xsp.webapp.FacesServlet$ExtendedServletException: java.lang.IllegalStateException: Can't get a Writer while an OutputStream is already in use"
This is my code below.
<xp:this.beforeRenderResponse><![CDATA[#{javascript:
try {
// Get the output stream
var exCon = facesContext.getExternalContext();
var response = exCon.getResponse();
var out = response.getOutputStream();
//Set the output stream to return a PDF file
response.setContentType("application/pdf");
var currentTime = new Date()
var month = currentTime.getMonth() + 1
var day = currentTime.getDate()
var year = currentTime.getFullYear();
var hours = currentTime.getHours();
var minutes = currentTime.getMinutes();
filetitle = "attachment; filename=Action_Plan_"+day+"-"+month+"-"+year+"_"+hours+"."+minutes+".pdf"
response.setHeader("Content-disposition",filetitle);
response.setHeader("Cache-Control", "no-cache");
//Stream the file to the browser
var doc:com.itextpdf.text.Document = new com.itextpdf.text.Document(com.itextpdf.text.PageSize.LETTER.rotate());
com.itextpdf.text.pdf.PdfWriter.getInstance(doc, out);
doc.open();
doc.addAuthor("");
doc.addCreationDate();
doc.addTitle("PDF");
//get user id
key = context.getUrl().getParameter("documentId");
var srcView = database.getView("lookup-actions-id")
dc = srcView.getAllDocumentsByKey(key, true);
var currdoc:NotesDocument = database.getDocumentByUNID(context.getUrl().getParameter("documentId"));
var myFont:com.itextpdf.text.Font = new com.itextpdf.text.Font();
myFont.setSize(9);
var head1Font:com.itextpdf.text.Font = new com.itextpdf.text.Font();
head1Font.setStyle(com.itextpdf.text.Font.BOLD);
head1Font.setSize(20)
var head2Font:com.itextpdf.text.Font = new com.itextpdf.text.Font();
head2Font.setStyle(com.itextpdf.text.Font.BOLD);
head2Font.setSize(15)
//add all content for the pdf here
//========================================================================
//Create an image
var imageUrl:String = context.getUrl().toString().split(view.getPageName())[0] +"/images/logo.gif"
var image:com.itextpdf.text.Image = com.itextpdf.text.Image.getInstance(new java.net.URL(imageUrl));
image.setAbsolutePosition(300f, 765f);
doc.add(image);
doc.add(new com.itextpdf.text.Paragraph("Title", head2Font))
var line = currdoc.getItemValueString("Person_FirstName")+" "+currdoc.getItemValueString("Person_SurName");
//var line = currdoc.getItemValueString("MTG_Person");
doc.add(new com.itextpdf.text.Paragraph(line));
doc.add(new com.itextpdf.text.Paragraph(' '));
//Create a table with 11 rows, 6 columns, width = 100%
var table = new com.itextpdf.text.pdf.PdfPTable(6); // 2 columns.
table.setSpacingBefore(10);
table.setSpacingAfter(10);
table.setWidthPercentage(100);
doc.add(table);
//========================================================================
doc.close();
} catch (e) {
print("Error generating dynamic PDF: " + e.toString());
} finally {
facesContext.responseComplete();
}
// Stop the page from further processing;
facesContext.responseComplete();
out.close();
}]]></xp:this.beforeRenderResponse></xp:view>
Any ideas where I should be looking.
Cheers