이클립스 jsp dead code 오류

이클립스 jsp dead code 오류

작성일 2023.06.08댓글 1건
    게시물 수정 , 삭제는 로그인 필요

jsp sqlserver를 연동하며 예제를 실행해 보고 있는데 dead code가 떠서 해결법 좀 알려주세요
밑줄이 그어져있는 UserDAO userDAO = new UserDAO (); 가 dead code 오류가 뜨면서 아래 코드들이 
작동을 안 하네요

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

pageEncoding="UTF-8"%>

<%@ page import="user.UserDTO"%>

<%@ page import="user.UserDAO"%>

<%@ page import="java.io.PrintWriter"%>

<%


request.setCharacterEncoding("UTF-8");

String userID = null;

String userPassword = null;

if(request.getParameter("userID") != null){

userID = (String) request.getParameter("userID");

}

if(request.getParameter("userPassword") != null){

userID = (String) request.getParameter("userPassword");

}

if(userID == null || userPassword == null){

PrintWriter script = response.getWriter();

script.println("<script>");

script.println("alert('입력이 안된 사항이 있습니다.');");

script.println("history.back();");

script.println("</script>");

script.close();

return;

}

UserDAO userDAO = new UserDAO();

int result = userDAO.join(userID, userPassword);

if (result == 1) {

PrintWriter script = response.getWriter();

script.println("<script>");

script.println("alert('회원가입에 성공했습니다.');");

script.println("location.href = 'Test01.jsp';");

script.println("</script>");

script.close();

return;

}


%>



#이클립스 jsp #이클립스 jsp 자동완성 #이클립스 jsp 주석 단축키 #이클립스 jsp 실행 #이클립스 jsp validation 끄기 #이클립스 jsp 한글깨짐 #이클립스 jsp 디버깅 #이클립스 jsp 주석 색깔 #이클립스 jsp 프로젝트 생성 #이클립스 jsp 에디터

profile_image 익명 작성일 -

안녕하세요. 답변드려요.

UserDAO userDAO = new UserDAO(); 가 Dead code 오류가 발생하는 이유는 해당 코드가 사용되지 않은 상태에서 선언되었기 때문입니다.

해결 방법으로는 아래와 같은 단계를 따르시면 됩니다.

1. UserDAO userDAO = new UserDAO(); 이 부분을 삭제해주세요.

2. 코드를 재작성하여, 사용되지 않는 변수나 객체를 제거해주세요.

3. 코드를 다시 실행해보세요.

위의 단계를 따르면 Dead code 오류를 해결할 수 있습니다. 만약에 이 방법이 도움이 되지 않는다면, 더 자세한 내용을 파악하기 위해서는 에러 메시지를 더 자세히 살펴보아야 합니다.

답변확정 부탁합니다.