직업은 선물 트레이더

[과제]웹프로그래밍. JSP기반 BMI 측정 소프트웨어

잊어버린 과거

JSP를 사용하는 첫 번째 과제였던 것 같다. 워낙은 서버의 데이터베이스에 아이디와 비밀번호 등이 저장되어있어서 조회 하는 방식으로 로그인 처리를 해야하지만, 그런 거 없다.. 폼에 입력된 데이터를 어떻게 JSP 언어에서 사용하는지 정도를 배우는 것이 목적이었던 것 같다. 

 

 

[BMI 계산 + Login ]

컴퓨터공학과 2010151035 장용하. (10/10 제출)



SOURCE CODE(login.htm)


<!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>Insert title here</title>

</head>

<body>

        관리자 (Master)로 로그인 하세요.<br/>

        <form action="loginProcess2.jsp" method = "post">

                ID : <input type = "text" name = "id"><br/>

                Password : <input type = "password" name="pw"><br/>

                <input type="submit" value="전송">

        </form>

</body>

</html>



SOURCE CODE(loginProcess.jsp)


<%@ 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">

<%

        String storedID = application.getInitParameter("MasterID");

        String storedPW = application.getInitParameter("MasterPassword");

        

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

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

        

        if(id.equals(storedID) && pw.equals(storedPW)) {

                session.setAttribute("MasterLoginID", id);   

%>

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=EUC-KR">

<title>Insert title here</title>

</head>

<body>

        로그인에 성공했습니다.<br/><br/>

        

        ※BMI체크하기

        <form action="loginAndBmiCheck.jsp">

                키 : <input type="text" name="height">cm<br/>

                몸무게 : <input type="text" name="weight">kg<br/>

                <input type=submit value="계산">

        </form>

        


</body>

</html>

<%

                String IDStore = request.getParameter("idsotre");

                if(IDStore != null && IDStore.equals("store")) {

                        Cookie cookie = new Cookie("id", id);

                        response.addCookie(cookie);

                        out.println("<a href = 'login2.jsp'>로그인 화면 다시 보기</a>");

                }

        }

        else if(id.equals(storedID)) {

%>

<script>

alert("패스워드가 다릅니다.");

history.go(-1);

</script>

<%

        }

        else {

%>

<script>

alert("로그인  ID가 다릅니다.");

history.go(-1);

</script>

<%

        }

%>



SOURCE CODE(loginAndBmiCheck.jsp)


<%@ 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">

<%

        String masterID = (String)session.getAttribute("MasterLoginID");

        boolean isLogin = false;

        if(masterID != null) {

                isLogin = true;

        }

%>

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=EUC-KR">

<title>Insert title here</title>

</head>

<body>

        <%

                if(isLogin) {

        %>

        아이디 "<%= masterID %>"로 로그인 한 상태 <br/>


        <%

                String THeight = request.getParameter("height");

                String TWeight = request.getParameter("weight");

                Double RHeight = Double.parseDouble(THeight);

                Double RWeight = Double.parseDouble(TWeight);

                

                RHeight = RHeight/100;

        

                double bmi = RWeight / (RHeight*RHeight);

        %>

        

        

        Your height : <%= THeight %> cm <br/>

        Your weight : <%= TWeight %> kg <br/><br/>

        and Your BMI is : <%= bmi %> <br/> ※ Comment :

        

        <% if(bmi > 25) %> 살한테 매달려가지고 바지끄댕이 매달려가지고 응딩이 살 응딩이 뒤에서 숨어가지고 형님형님 형님백만 믿겠다! 이게 다이어트 한다는 사람의 제대로된 의식일수가 있겠습니까? 그렇지 않겠습니까?

        <% if(bmi > 20 && bmi <=25) %> 정상 몸무게 한테 매달려가지고 바지끄댕이 매달려가지고 응딩이 정상 몸무게 응딩이 뒤에서 숨어가지고 형님형님 형님백만 믿겠다! 이게 건강하다는 사람의 제대로된 의식아니겠습니까? 그렇지 않겠습니까?  

        <% if(bmi <= 20 ) %> 멸치한테 매달려가지고 바지끄댕이 매달려가지고 응딩이 멸치 응딩이 뒤에서 숨어가지고 형님형님 형님백만 믿겠다! 이게 건강하다는 사람의 제대로된 의식일수가 있겠습니까? 그렇지 않겠습니까?     


        <br/><br/>


<a href = "logout.jsp">로그아웃</a>

<%

        }

        else {

%>

로그인하지 않은 상태

<%

        }

%>

</body>

</html>



SOURCE CODE(logout.jsp)


<%@ 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">

<% session.invalidate(); %>

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=EUC-KR">

<title>Insert title here</title>

</head>

<body>

로그아웃 하셨습니다.

<a href = "login.htm">처음부터</a>

</body>

</html>

 



Demonstration


 

BMI 계산 소프트웨어 결과