java.lang.IllegalStateException: getOutputStream() has already been called

Could anyone suggest what would be the problem in belo code in JSP page.

I am working on MVC1 JSP application.I have request processing code in jsp before <HTML> tags.

I have functionality of downloading file by hyperlink "download file".

In click of this file fiel is downloading without any errors.

But i get an error in JSP page as below.

My Logs in JSP showsi get this error immediatly after "<HEAD>" tag.

Could anyone provide suggestion on this to fix the problem

--

JSP

if(blnFileDownload){

dowloadFiles.downloadFile(request, response);

log.log(Level.DEBUG,"file download action completed..");

}

log.log(Level.DEBUG,"end of request processing code..");

//end of request processing code

%>

<%log.log(Level.DEBUG,"==== end of bussiness logic====");%>

<!-- WARNING: This has only been tested in MSIE6 @ 1280 x 1024 Resolution -->

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<%log.log(Level.DEBUG,"1====100");%>

<HTML>

<%log.log(Level.DEBUG,"1====101");%>

<TITLE>EVM - Master Data Maintenance</TITLE>

<%log.log(Level.DEBUG,"1====102");%>

<HEAD>

<%log.log(Level.DEBUG,"====HEAD START====");%>

-

LOGS

2007-07-27 09:48:37,722 DEBUG documentsmaster.jsp - ====HEAD START====

2007-07-27 09:48:37,722 INFO error.jsp - Master error loaded..

2007-07-27 09:48:37,722 ERROR error.jsp - Exception - java.lang.IllegalStateException: getOutputStream() has already been called for this response

[1641 byte] By [raghuveer_vellankia] at [2007-11-27 11:52:46]
# 1

Put this code into a servlet rather than a JSP.

You should only call getOutputStream() / getWriter() once for any request/response.

I presume the downloadFiles.downloadFile() call makes a call to getOutputStream()?

The JSP also has an implicit call to getWriter - to get the JSPWriter

If you are wanting to send a file in response, then don't use a JSP. Use a servlet which doesn't make that implicit call to screw things up.

Cheers,

evnafets

evnafetsa at 2007-7-29 18:46:31 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...