MitchBroadhead
asked on
writing to response stream from action
trying to call an action in a jsp page to return some html on http response stream, but it doesn't seem to like it. i am using the itext library's html writer.
i have an action-mapping where /ledger.do maps to Ledger.class which is an action.
in ledger.jsp:
<jsp:include page="/ledger.do" />
in Ledger.java:
ServletOutputStream out = response.getOutputStream() ;
response.setContentType("t ext/html") ;
HtmlWriter.getInstance(doc ument, out);
the problem is that the http headers have already been sent so...
is there any way to write html back to the response stream?
I don't mind changing class type to httpservlet.
i have an action-mapping where /ledger.do maps to Ledger.class which is an action.
in ledger.jsp:
<jsp:include page="/ledger.do" />
in Ledger.java:
ServletOutputStream out = response.getOutputStream()
response.setContentType("t
HtmlWriter.getInstance(doc
the problem is that the http headers have already been sent so...
is there any way to write html back to the response stream?
I don't mind changing class type to httpservlet.
Think I misinterpreted your question.
Have you tried increasing the buffer in the jsp page (thereby giving your action and itext more chance of altering the headers before they are written)
Have you tried increasing the buffer in the jsp page (thereby giving your action and itext more chance of altering the headers before they are written)
I think you will need to write a servlet, not a Struts action to do this task...
ASKER
ideally i would like to output to the http stream without headers, to allow the html to be embedded into the page
ASKER
fixed
used ByteArrayOutputStream to store the output of itext htmlwriter, then usedbaos.toString() to pump into response.getWriter().
used ByteArrayOutputStream to store the output of itext htmlwriter, then usedbaos.toString() to pump into response.getWriter().
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
(the jsp's implicit out variable is a wrapper (indirectly) for response.getWriter - and you cannot call both getWriter and getOutputStream without throwing an exception (according to the specs))