-
if(session.getAttribute("userId") != null || session.getAttribute("userId") !="" ) 사용시 에러WEB/JSP 2018. 10. 5. 13:46
사용환경
jdk 1.9
eclipse oxygen
tomcat v8.5
JSP 공부를 하던차에 아래와 같이 사용하면 에러가 발생함을확인, 정확한 원인은 아직 파악못했으나
일단은, 아래와 같이 사용하면 에러가 발생함을 확인했다.
if(session.getAttribute("userId") != null || session.getAttribute("userId") !="" )
공부중이던 소스
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<%-- || session.getAttribute("userId") !="" --%>
<%
if(session.getAttribute("userId") != null ){
response.sendRedirect("/index/index.jsp");
} else{
out.println("<script>alert('로그인 해라 시바')</script>");
}
%>
<form action="loginChk">
id:<input type="text" name="userId"><br>
pw:<input type="password" name="userPw"><br>
<input type="submit" name="login">
<input type="submit" name="signup">
</form>
</body>
</html>
해결책은 || 이후의 부분을 지우는 방법이 있는데, 그 외의 방법은 아직 파악하지 못했다.
이 글을 보고 위 해결책 외에 해답이 있다면 공유 해주시면 도움이 되겠습니다.
'WEB > JSP' 카테고리의 다른 글
jsp 경로를 이동하면 파일 다운로드 받는 방법 (0) 2018.10.23 JSP 에러페이지 (0) 2018.10.23 web.xml 파일이 없을때 해결법 (1) 2018.10.23 eclipse에서 mysql 연동 에러 문제 (0) 2018.10.19 Access restriction: The method 'ServletRequest.getRemoteAddr()' is not API (0) 2018.09.14 댓글