This week's book giveaway is in the Android forum. We're giving away four copies of Android Programming: The Big Nerd Ranch Guide and have Bill Phillips & Chris Stewart on-line! See this thread for details.
You'll have a much easier time doing this from a servlet than from a JSP. If you have so much as a single whitespace character preceding your scriptlet that references the outputstream, you will see this error.
Any whitespace after it will also cause this problem. JSPs are best for formatting text (html).