JSP

211012_form전송(back)

요옫 2021. 10. 12. 15:37

html

<!DOCTYPE html>

<html>

<head>

<meta charset="UTF-8">

<title>Insert title here</title>

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">

<script src="https://code.jquery.com/jquery-3.5.0.js"></script>

<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>

</head>

<body>

<h3>폼태그 연습_#3</h3>

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

  <table class="table table-bordered" style="width: 300px;">

    <tr>

      <th width="100">이름</th>

      <td>

        <input type="text" name="name" class="form-control" required="required">

      </td>

    </tr>

    

    <tr>

      <th width="100">비밀번호</th>

      <td>

        <input type="password" name="pass" class="form-control" required="required"

         pattern="[0-9]{1,4}"> <!-- 0-9숫자만 가능, 길이는 1-4까지만 -->

      </td>

    </tr>

    

    <tr>

      <td colspan="2" align="center">

        <button type="submit" name="btn btn-info" >서버로 전송</button>

      </td>

    </tr>

  </table>

</form>

</body>

</html>

 

 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

 

 

formaction.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"

    pageEncoding="UTF-8"%>

<!DOCTYPE html>

<html>

<head>

<meta charset="UTF-8">

<title>Insert title here</title>

<link href="https://fonts.googleapis.com/css2?family=Nanum+Pen+Script&display=swap" rel="stylesheet">

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">

<script src="https://code.jquery.com/jquery-3.5.0.js"></script>

<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>

</head>

<body>

<%

request.setCharacterEncoding("utf-8");

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

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

%>

 

<h3>ex12 결과 출력</h3>

이름: <%=name %><br>

비밀번호: <%=pass %><br>

 

<!-- a태그 이용해서 다시 입력할 수 있게 -->

<a href="ex12_form.html">다시 입력</a>

<!-- 자바스크립트 태그: 이전 -->

<a href="javascript:history.back()">다시 입력</a>

</body>

</html>

 

 

 

 

 

 

'JSP' 카테고리의 다른 글

211019_복습(jsp)  (0) 2021.10.19
211019_jsp로 게시판 만들기  (0) 2021.10.19
211012_form전송(checkbox, radio,select,array)  (0) 2021.10.12
211012_form전송(checkbox)  (0) 2021.10.12
211012_form전송(post,get)  (0) 2021.10.12