프로그래머/JAVA

[JSP] get, post, Scriptlet, 표현식(Expression), 선언(Declaration)

얼짱가면 2013. 3. 26. 10:10

get, post 비교.

<%  %> Scriptlet은 클라이언트별로 값이 다름.

<%! %> 선언 : 웹어플리케이션이 재시작되기 전까지 값 유지.

 

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

<html>

<head>

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

<title>Insert title here</title>

</head>

<body>

        <form action = "declarationTest.jsp" method="get">

        이름 : <input type="text" name = "userName"/>

        암호 : <input type="password" name = "userPass"/>

        <input type="submit" value="전송 버튼"/>

        </form>

</body>

</html>

 

 

 

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

<html>

<head>

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

<title>Insert title here</title>

</head>

<body>

        <%! int totalCount; %>

        <%

        request.setCharacterEncoding("EUC-KR");

        String paramName = request.getParameter("userName");

        String paramPass = request.getParameter("userPass");

        totalCount++;

        %>

        이름 : <%=paramName %> <br/>

        암호 : <%=paramPass %> <br/>

        방문자는 <%= totalCount %>명입니다.<br/>

</body>

</html>