STATUS : Closed
Scenario :
jsp to generate a report and on click of a button download the report xls from the server. Code in the jsp is as follows.
response.setContentType("application/vnd.ms-excel");
response.setHeader("Content-Disposition",
"attachment; filename=Report.xls");
OutputStream out1 =response.getOutputStream();
WritableWorkbook workbook = Workbook.createWorkbook(out1);
Resolution :
Moved the code in the jsp to a servelet
Possible RootCause :
You cannot get a handle to the multiple output stream objects. When the jsp code gets compiled to plain java it adds code " out.write() " to write the jsp content to the outputstream. Since you already have got a handle to the ouputstream the out.write() system code throws the exception. Hence moving the code to a servelet solves the issue.
250x250
Notice
Recent Posts
Recent Comments
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |
Tags
- 설정
- ubuntu
- git
- AJAX
- Core Java
- Spring Boot
- oracle
- Eclipse
- JavaScript
- jpa
- MSSQL
- SpringBoot
- Tomcat
- Exception
- myBatis
- Docker
- Thymeleaf
- 문서
- Python
- Source
- IntelliJ
- spring
- JDBC
- Open Source
- maven
- STS
- PostgreSQL
- error
- 오픈소스
- MySQL
Archives
- Today
- Total
헤르메스 LIFE
[Exception] [java.lang.IllegalStateException: getOutputStream() has already been called for this response] with root cause 본문
Exception
[Exception] [java.lang.IllegalStateException: getOutputStream() has already been called for this response] with root cause
헤르메스의날개 2013. 7. 29. 15:46728x90
java.lang.IllegalStateException: getOutputStream() has already been called for this response
out.clear();
out=pageContext.pushBody();
요 두줄을 OutputStream하기 전에 넣어주면 되겠다. out은 jsp 웹페이지 자신을 가리키는 것 ! ! !
jsp에서는 servlet으로 변환될때 내부적으로 out 객체가 자동으로 생성되기 때문에 따로 out 객체를 만들면 충돌이 일어나서 저런 메시지가 뜨는 것이라고 한다.
out.clear();
out=pageContext.pushBody();
BufferedInputStream fin = new BufferedInputStream(new FileInputStream(file));
OutputStream outs = response.getOutputStream();
728x90