메뉴 바로가기 검색 및 카테고리 바로가기

한빛미디어

뇌를 자극하는 JSP & Servlet

뇌를 자극하는 JSP & Servlet 질의응답 게시판입니다.

13 장에서 Stream closed 나오는 것

2013-07-12

|

by 벤지

6932

13장에서 750 Page 의 설정을 한 이후 실행해보면 브라우져에 제대로 결과가 나옵니다.
그런데 Eclipse 의 Console 화면에 아래와 같은 내용이 계속 출력되는데
제가 무엇을 잘못한것인지 부탁 드리겠습니다.

[ 작업 환경 ]-------------------------------------------------------

- Eclipse ( Juno )
- Tomcat 7
- JDK 1.7


[ 에러 내용 ]-------------------------------------------------------

SEVERE: Servlet.service() for servlet [jsp] in context with path [/brain13] threw exception [java.lang.IllegalStateException: Exception occurred when flushing data] with root cause
java.io.IOException: Stream closed
        at org.apache.jasper.runtime.JspWriterImpl.ensureOpen(JspWriterImpl.java:210)
        at org.apache.jasper.runtime.JspWriterImpl.flushBuffer(JspWriterImpl.java:115)
        at org.apache.jasper.runtime.PageContextImpl.release(PageContextImpl.java:190)
        at org.apache.jasper.runtime.JspFactoryImpl.internalReleasePageContext(JspFactoryImpl.java:126)
        at org.apache.jasper.runtime.JspFactoryImpl.releasePageContext(JspFactoryImpl.java:80)
        at org.apache.jsp.WebTemplate_jsp._jspService(WebTemplate_jsp.java:126)
        at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
        at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
        at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
        at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
        at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
        at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:947)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
        at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1009)
        at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
        at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
        at java.lang.Thread.run(Thread.java:722)

[  WebTemplate.jsp ]-------------------------------------------------------

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>




Insert title here



템플릿 테스트




  
  
  
  

      회사소개

      책정보
게시판글쓰기

      게시판글읽기
  






[  BBSListView.jsp ]-------------------------------------------------------

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>


게시판 목록




  
  
  
  
  
  
  
  
  

    
    
    
    
    
  
  
순번제목작성자작성일작성시각
${BBS_LIST.seqNo[cnt]}${BBS_LIST.title[cnt]}${BBS_LIST.writer[cnt]}${BBS_LIST.date[cnt]}${BBS_LIST.time[cnt]}



  Next


[  BBSListServlet.java ]-------------------------------------------------------

package web;

import java.io.IOException;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.bg.bgutil;

public class BBSListServlet extends HttpServlet
{
    private static final long serialVersionUID = -6841908212744138097L;
    
    public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
    {
        request.setCharacterEncoding("utf-8");
        
        String strUpperSeqNo = request.getParameter("seqno");
        
        int upperSeqNo;
        
        if (strUpperSeqNo == null)
            upperSeqNo = Integer.MAX_VALUE;
        else
            upperSeqNo = Integer.parseInt(strUpperSeqNo);
        
        BBSList list = readDB(upperSeqNo);
        request.setAttribute("BBS_LIST", list);
        
        RequestDispatcher dispatcher = request.getRequestDispatcher("WebTemplate.jsp?BODY_PATH=BBSListView.jsp");
        // RequestDispatcher dispatcher = request.getRequestDispatcher("BBSListView.jsp");
        dispatcher.forward(request, response);
    }
    
    private BBSList readDB(int upperSeqNo) throws ServletException
    {
        BBSList list = new BBSList();
        
        Connection conn = null;
        Statement stmt = null;
        
        try
        {
            Class.forName("org.apache.commons.dbcp.PoolingDriver");
            conn = DriverManager.getConnection("jdbc:apache:commons:dbcp:/wdbpool");
            if (conn == null) throw new Exception("DB Connect Error");
            
            stmt = conn.createStatement();
            ResultSet rs = stmt.executeQuery("select * from bbs where seqno < " + upperSeqNo + " order by seqno desc;");
            
            for (int cnt = 0; cnt < 5; cnt++)
            {
                if (!rs.next()) break;
                
                list.setSeqNo(cnt, rs.getInt("seqno"));
                list.setTitle(cnt, bgutil.toUnicode(rs.getString("title")));
                list.setWriter(cnt, bgutil.toUnicode(rs.getString("writer")));
                list.setDate(cnt, rs.getDate("wdate"));
                list.setTime(cnt, rs.getTime("wtime"));
            }
            
            if (!rs.next()) list.setLastPage(true);            
        }
        catch (Exception e)
        {
            throw new ServletException(e);
        }
        finally
        {
            try
            {
                stmt.close();
            }
            catch (Exception e)
            {
            }
            
            try
            {
                conn.close();
            }
            catch (Exception e)
            {
            }
        }
        
        return list;
    }
    
}
댓글 입력
자료실