Solved

writing to response stream from action

Posted on 2004-03-30
7
292 Views
Last Modified: 2008-03-10
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("text/html");
HtmlWriter.getInstance(document, 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.
0
Comment
Question by:MitchBroadhead
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 7

Expert Comment

by:searlas
ID: 10713534
Use getWriter, not getOutputStream and you won't have a problem.
(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))
0
 
LVL 7

Expert Comment

by:searlas
ID: 10713543
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)
0
 
LVL 35

Expert Comment

by:TimYates
ID: 10713560
I think you will need to write a servlet, not a Struts action to do this task...
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Author Comment

by:MitchBroadhead
ID: 10713645
ideally i would like to output to the http stream without headers, to allow the html to be embedded into the page
0
 
LVL 1

Author Comment

by:MitchBroadhead
ID: 10715844
fixed

used ByteArrayOutputStream to store the output of itext htmlwriter, then usedbaos.toString() to pump into response.getWriter().
0
 
LVL 1

Accepted Solution

by:
Computer101 earned 0 total points
ID: 10908985
PAQed, with points refunded (125)

Computer101
E-E Admin
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
how to install java on RHEL image on EC2 4 57
mysql jsp example issue 32 73
Cisco ASA: Java web start no go, asdm launcher no go 3 58
web project error add remove 1 54
An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question