강의

멘토링

커뮤니티

Inflearn Community Q&A

wlsdnd9112381's profile image
wlsdnd9112381

asked

Creating a JSP community bulletin board where anyone can learn by following along

Implementing login functionality

loginAction에서 histoty.back 안되시는 분들 보세요~

Written on

·

510

1

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

back 뒤에 () 붙여주시면 정상동작 됩니다!

모두 즐거운 코딩 되세요~

---------------------------------------------

::: 제가 쓴 코드도 혹시 모르니 올려드릴게요 :::

UserDAO userDAO = new UserDAO();

int result = userDAO.login(user.getUserID(), user.getUserPassword());

if(result == 1){

PrintWriter script = response.getWriter();

script.println("<script>");

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

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

}

else if(result == 0){

PrintWriter script = response.getWriter();

script.println("<script>");

script.println("alert('비밀번호가 틀립니다.');");

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

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

}

else if(result == -1){

PrintWriter script = response.getWriter();

script.println("<script>");

script.println("alert('존재하지 않는 아이디입니다.');");

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

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

}

else if(result == -2){

PrintWriter script = response.getWriter();

script.println("<script>");

script.println("alert('데이터베이스 오류가 발생하였씁니다.');");

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

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

}

jspjava

Answer

This question is waiting for answers
Be the first to answer!
wlsdnd9112381's profile image
wlsdnd9112381

asked

Ask a question