<form name="입력 폼 이름" action="웹 프로그램 페이지" method="전달 방식">

<input type="폼 모양과 기능" name="입력 폼 변수" value="전달 값">

</form>





이렇게 html에서 하려고 했는데 오류나서


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

    <!--action은 서버 쪽 주소(jsp로 구성), 여기에서는 html에 보냄-->

    <table>

        <tr>

            <td>ID</td>

            <td>

                <input type="text" name="id" id="id">

                <!-- 서버에서는 name으로, 자바스크립트는 id로 인식하므로 둘의 이름을 같게 명시해야 한다-->

            </td>

        </tr>

        <tr>

            <td>암호</td>

            <td><input type="password" name="pw" id="pw"></td>

        </tr>

        <tr>

            <td colspan="2"></td><!--컬럼 2칸 합치기-->

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

        </tr>

    </table>

    </form>






이클립스에서 이렇게 jsp로 다시 함


클래스명 : myForm1.jsp

여기에서 id와 pw입력 하면


<?xml version="1.0" encoding="EUC-KR" ?>

<%@ page language="java" contentType="text/html; charset=EUC-KR"

    pageEncoding="EUC-KR"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

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

<title>Insert title here</title>

</head>

<body>

<%

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

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

if(id != null){

out.println("ID : " + id);

}

if(pw != null){

out.println("암호 : " + pw);

}

%>

</body>

</html>





클래스명 : myForm2.jsp

여기에 출력 됨


<!-- if(id != null){

out.println("ID : " + id);

}

if(pw != null){

out.println("암호 : " + pw);

} -->


<?xml version="1.0" encoding="EUC-KR" ?>

<%@ page language="java" contentType="text/html; charset=EUC-KR"

    pageEncoding="EUC-KR"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

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

<title>Insert title here</title>

</head>

<body>

<%

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

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

%>

<table>

<tr>

<td>ID</td>

<td>

<%= id %>

</td>

</tr>

<tr>

<td>PW</td>

<td>

<%= pw %>

</td>

</tr>

</table>

</body>

</html>

+ Recent posts