전송방식은 따로 지정해주지 않은한 기본값은 get방식
웹 브라우저를 실행한 후 URL뒤에 "?memberId=apple" 작성후 이동하면 조건문에 의해 응답화면으로 이동
실패할 경우 계속 페이지에 머문다.
<%@ page contentType="text/html; charset=utf-8" %>
<%
    String id=request.getParameter("memberId");//id에 memberId의 값 요청한 것을 저장
    if(id!=null && id.equals("apple")){//id이 null이 아니고 apple이면
        response.sendRedirect("https://www.google.com");//google사이트로 이동
    }else{
%>
<html>
<head>
    <meta charset="utf-8">
    <title>로그인에 실패</title>
</head>
<body> 
    잘못된 아이디 입니다.
</body>
</html>
<%  }%>

 

 

 

반응형

'JSP' 카테고리의 다른 글

[JSP] 개발 페이지 분류  (0) 2021.07.09
[JSP] JSP의 동작원리  (0) 2021.07.09
[JSP] response 기본 객체  (0) 2021.07.08
[JSP] get/post 전송방식 차이  (0) 2021.07.08
[JSP] request(요청) 기본 객체  (0) 2021.07.08

+ Recent posts