response truncated after switch from ServletOutputStream to OutputStreamWriter

Posted on 2006-04-27
Last Modified: 2011-10-03

I had a servlet that was writing html output using;

ServletOutputStream out = response.getOutputStream();
out.println(" ... ");

I changed this to:
ServletOutputStream out = response.getOutputStream();
OutputStreamWriter outputWriter = new OutputStreamWriter(out);
outputWriter.write(" ... ");

Now when I browse to the Servlet I get _most_ of the HTML printed to my browser, but the output seems to stop after a certain number of characters.  Is there something wrong with the way I'm using OutputStreamWriter; odes it have a finite buffer size?

Question by:blackfrancis75
    1 Comment
    LVL 92

    Accepted Solution

    try doing a flush() after you've written all the output

    Featured Post

    6 Surprising Benefits of Threat Intelligence

    All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

    Join & Write a Comment

    Suggested Solutions

    Title # Comments Views Activity
    java constructor error 8 65
    Fibonacci challenge 11 61
    strCopies  challenge 17 60
    Running Jira on Raspberry PI 2? 3 45
    In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
    Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
    Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
    Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…

    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

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now