정수리
309
2015-08-09 23:10:06
2
1485

장바구니를 구현중인데 jsp 파일에서 값을 null값으로 받아와요 ㅜㅜ,-2 java.lang.IllegalStateException: Cannot forward after response has been committed


이전에 상세페이지에서 장바구니를 넘길때 null 값이넘어간다고 하여서 글을올렸습니다.

친절하시게도 답변을 달아주셨는데 java스크립트를 써서 값을 넘기라고 하셨는데 제가 javascript는 사용할줄을 몰라서 다른 방식으로 소스를 바꿨습니다.

일단 db에는잘들어 가는데 오류가 뜹니다 ㅜ.ㅜ 어떤내용의 오류인지 잘모르겠습니다 ㅜ.ㅜ


오류내용

심각: Servlet.service() for servlet [jnmk.basket.action.BasketFrontController] in context with path [/JSHOW_1] threw exception

java.lang.IllegalStateException: Cannot forward after response has been committed

at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:348)

at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:338)

at jnmk.basket.action.BasketFrontController.doProcess(BasketFrontController.java:56)

at jnmk.basket.action.BasketFrontController.doGet(BasketFrontController.java:63)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:624)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:731)

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)

at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)

at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)

at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)

at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:505)

at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)

at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)

at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:957)

at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)

at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:423)

at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1079)

at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:620)

at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:318)

at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)

at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)

at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)

at java.lang.Thread.run(Thread.java:745)



제품 상세 페이지


<%@ page language="java" contentType="text/html; charset=EUC-KR"
	pageEncoding="EUC-KR"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=EUC-KR">
<title>재능상세 페이지</title>
</head>
<body>
	<!-- GoodsDetailAction에서 넘어온 값이 JSTL(커스텀 액션) 사용하여 값을 뿌려줌 -->
	<table width="500" cellpadding="0" cellspacing="0" border="1">

		<form
			action="goods_modify_form.do?GOODS_NUM=${goods_detail_view.GOODS_NUM}" method="post">
			<input type="hidden" name="GOODSNUM"
				value="${goods_detail_view.GOODS_NUM}">
			<tr>
				<td>카테고리</td>
				<td><td><input type="hidden" name="CATEGORY1"
					value="${goods_detail_view.GOODS_CATEGORY1}">${goods_detail_view.GOODS_CATEGORY1}</td>
				<td>카테고리2</td>
				<td>${goods_detail_view.GOODS_CATEGORY2}</td>
			<tr>
				<td>등록번호</td>
				<td><input type="hidden" name="GOODSNUM" value="${goods_detail_view.GOODS_NUM}">${goods_detail_view.GOODS_NUM}</td>
			</tr>
			</tr>
			<tr>
				<td>이름</td>
				<td><input type="hidden" name="NAME" value="${goods_detail_view.GOODS_NAME}">${goods_detail_view.GOODS_NAME}</td>
			<tr>
			<tr>
				<td>재능상품명</td>
				<td><input type="hidden" name="SUBJECT"
					value="${goods_detail_view.GOODS_SUBJECT}">${goods_detail_view.GOODS_SUBJECT}</td>
			</tr>
			<td>금액</td>
			<td>${goods_detail_view.GOODS_PRICE}</td>
			</tr>
			<td>배송비</td>
			<td>${goods_detail_view.GOODS_PRICE2}</td>
			</tr>
			<tr>
				<td>사진</td>
				<td><img src="./upload/${goods_detail_view.GOODS_IMAGE}"
					width="200" height="200"></td>
			</tr>
			<tr>
				<td>섬네일</td>
				<td><img src="./upload/sm_${goods_detail_view.GOODS_IMAGE}"></td>
			</tr>
			<tr>
				<td>내용</td>
				<td>${goods_detail_view.GOODS_CONTENT}</td>
			</tr>
			<tr>
				<td>금액합계</td>
				<td><input type="hidden" name="TOTAL_PRICE"
					value="${goods_detail_view.GOODS_TOTAL_PRICE}">${goods_detail_view.GOODS_TOTAL_PRICE}</td>
			</tr>
			<tr>
				<td colspan="2"><input type="submit" value="수정">
					&nbsp;&nbsp; <a href="goods_list.do">목록보기</a> &nbsp;&nbsp; <a
					href="delete.do?GOODS_NUM=${goods_detail_view.GOODS_NUM}">삭제</a></td>
				<td><a href="BasketAdd.ba?GOODSNUM=${goods_detail_view.GOODS_NUM}">장바구니 담기</a>	
			</tr>
		</form>
	</table>

</body>
</html>

장바구니추가액션 


package jnmk.basket.action;



import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import jnmk.basket.db.BasketDAO;

public class BasketAddAction implements Action{
	public ActionForward execute(HttpServletRequest request, HttpServletResponse response)
	throws Exception{
		BasketDAO basketdao=new BasketDAO();
		HttpSession session=request.getSession();
		String email=(String)session.getAttribute("eamil");
		
		/*if(email==null){
			PrintWriter out=response.getWriter();
			out.println("<script>");
			out.println("history.go(-1)");
			out.println("</script>");
			out.close();
		}*/
		int goodsnum =Integer.parseInt(request.getParameter("GOODSNUM"));
		System.out.println("GoodsAddAction GOODS_NUM 값: "+goodsnum); //값 넘어온지 확인용
		
		basketdao.basketAdd(goodsnum,email);
		ActionForward forward=new ActionForward();
		forward.setRedirect(true);
		forward.setPath("./BasketList.ba");
		
		return forward;
	}
	
}


0
  • 답변 2

  • 손이시렵다
    1k
    2015-08-09 23:18:51
    return forward;를 return; 으로 한번 바꿔보세요
  • 정수리
    309
    2015-08-09 23:50:04
    retrun;해버리면 오류가 뜨네요;;
  • 로그인을 하시면 답변을 등록할 수 있습니다.