[Day3] JSP/Servlet 3 [12/6]

 

request ๊ฐ์ฒด ํŒŒ๋ผ๋ฏธํ„ฐ 

p 76  request ๊ฐ์ฒด์˜ ํŒŒ๋ผ๋ฏธํ„ฐ ์ฝ๊ธฐ ๋ฉ”์„œ๋“œ

    *** String      request.getParameter()  

    *** String[]   request.getParameterValues()

    

    Enumeration getparameterNames()

    Map               getParameterMap()

 

jsp

<form action="ex05_ok.jsp" method="post">
<!-- <form action="ex05_ok.jsp" method="get"> -->
   ์ด๋ฆ„ : <input type="text" name="name" placeholder="์ด๋ฆ„์„ ์ž…๋ ฅํ•˜์„ธ์š”"><br>
   ์„ฑ๋ณ„ : 
     <input type="radio" name="gender"  value="m" checked="checked"> ๋‚จ์ž
     <input type="radio" name="gender"  value="f">์—ฌ์ž<br>
    
   ์ข‹์•„ํ•˜๋Š” ๋™๋ฌผ :
      <input type="checkbox" name="pet" value="dog" checked="checked">๊ฐœ  
      <input type="checkbox" name="pet" value="cat">๊ณ ์–‘์ด  
      <input type="checkbox" name="pet" value="pig" checked> ๋ผ์ง€
      <br>    
   <input type="submit">
</form>

ok.jsp

   request.setCharacterEncoding("UTF-8");

    // ์Šคํฌ๋ฆฝํŠธ๋ฆฟ : ์ž๋ฐ”์ฝ”๋”ฉ.
    // ?name=ํ™๊ธธ๋™
    String name = request.getParameter("name");
    String gender = request.getParameter("gender"); // "m"  /  "f"
    
    // pet=dog&pet=cat
    String [] pets = request.getParameterValues("pet");
> ์ด๋ฆ„ : <%= name %><br>
> EL ์ด๋ฆ„ : ${  param.name }<br>
> ์„ฑ๋ณ„ : <%= gender.equals("m")? "๋‚จ์ž" :"์—ฌ์ž" %><br>
> ์ข‹์•„ํ•˜๋Š” ๋™๋ฌผ : <%= Arrays.toString(pets) %><br>
<hr>
<%
	// request.getParameterNames(): ์„ค๋ช…
	// ?[name]=admin&[gender]=m&[pet]=dog&pet=dog
	
	Enumeration<String> en = request.getParameterNames();
	while(en.hasMoreElements()){
		String pname = en.nextElement();
%>
	<li><%= pname %></li>
<%
	}
%>

<hr>
<ol>
<%
    //  pname,  pvalue 
	Map<String, String[]> map = request.getParameterMap();
	Set<Entry<String, String[]>> set = map.entrySet();
	Iterator<Entry<String, String[]>> ir = set.iterator();
	while(ir.hasNext()){
		Entry<String, String[]> entry = ir.next();
		String pname = entry.getKey();
		String[] pvalue = entry.getValue();
		%>
		<li><%= pname %> : <%= Arrays.toString(pvalue) %></li>
		<% 
	}
%>

    p 88 ~ request ๊ธฐ๋ณธ ๊ฐ์ฒด,  ์š”์ฒญ ํ—ค๋” ์ •๋ณด ์ฒ˜๋ฆฌ.

    p 89 ํ‘œ 3.6 ํ—ค๋” ๋ฉ”์„œ๋“œ

    ***   String getHeader(String name)  ์ง€์ •ํ•œ ์ด๋ฆ„์˜ ํ—ค๋” ๊ฐ’์„ ๋ฐ˜ํ™˜

    En       getHeaders(String name)     ์ง€์ •ํ•œ ์ด๋ฆ„์˜ ํ—ค๋” ๋ชฉ๋ก ๋ฐ˜ํ™˜

    ***  En       getHeaderNames()          ๋ชจ๋“  ํ—ค๋” ์ด๋ฆ„์„ ๋ฐ˜ํ™˜

    int       getIntHeader(String name)   ์ง€์ •ํ•œ ํ—ค๋”์˜ ๊ฐ’์„ ์ •์ˆ˜๋กœ ๋ฐ˜ํ™˜

    long     getDateHeader( String name) ์ง€์ •ํ•œ ํ—ค๋”์˜ ๊ฐ’์„ ์‹œ๊ฐ„๊ฐ’์œผ๋กœ ๋ฐ˜ํ™˜( 1970.1.1 ~  ms)

 

์š”์ฒญ ํ—ค๋“œ ๋ชฉ๋ก ์ถœ๋ ฅ

 <ol>
 <%
    Enumeration<String>  en = request.getHeaderNames();
    while( en.hasMoreElements() ){
    	String headerName =  en.nextElement();
    	String headerValue = request.getHeader(headerName);
%>
     <li><%= headerName %> : <%= headerValue %></li>
<%    	
    } // while
 %>  
 </ol>

    p 90 JSP ๊ธฐ๋ณธ  9๊ฐ€์ง€ ๊ฐ์ฒด : request  ์š”์ฒญ ๊ฐ์ฒด

              1) ํ—ค๋” ์ •๋ณด ์ฝ๊ธฐ.

              

    p 90 JSP ๊ธฐ๋ณธ๊ฐ์ฒด : [ response ์‘๋‹ต ๊ฐ์ฒด ] ๊ธฐ๋Šฅ

* request ๊ธฐ๋ณธ ๊ฐ์ฒด๊ฐ€ ์›น ๋ธŒ๋ผ์šฐ์ €๊ฐ€ ์ „์†กํ•œ ์š”์ฒญ ์ •๋ณด๋ฅผ ๋‹ด๊ณ ์žˆ๋‹ค๋ฉด, reponse ๊ธฐ๋ณธ ๊ฐ์ฒด๋Š” ์›น ๋ธŒ๋ผ์šฐ์ €์— ๋ณด๋‚ด๋Š” ์‘๋‹ต ์ •๋ณด๋ฅผ ๋‹ด๋Š”๋‹ค.

 

 

    p 90 JSP ๊ธฐ๋ณธ๊ฐ์ฒด : [ response ์‘๋‹ต ๊ฐ์ฒด ] ๊ธฐ๋Šฅ

       1) ํ—ค๋” ์ •๋ณด ์ž…๋ ฅ(์„ค์ •)

          p91  ํ‘œ 3.7  ํ—ค๋” ์ •๋ณด ์ถ”๊ฐ€ ๋ฉ”์„œ๋“œ

          addDateHeader( name, long) 
          addHeader(name, value);
          addIntHeader(name, value)
          
          setDateHeader()
          setHeader()
          setIntHeader()
          
          boolean  containsHeader( name )

          

          

       2) *** ๋ฆฌ๋‹ค์ด๋ ‰ํŠธ(redirect) ํ•˜๊ธฐ  ***   p 93

          - ํŽ˜์ด์ง€ ์ด๋™ํ•˜๋Š” ๊ธฐ๋Šฅ

          - ์‚ฌ์ „์  ์˜๋ฏธ : ๋‹ค๋ฅธ ๋ฐฉํ–ฅ์œผ๋กœ ๋‹ค์‹œ ๋ณด๋‚ด๋‹ค(์ „์†กํ•˜๋‹ค)

             ๊ทธ๋ฆผ 3.19         ๋ฆฌ๋‹ค์ด๋ ‰ํŠธ 

               ใ„ฑ.       ํด๋ผ์ด์–ธํŠธ      <-      ์‘๋‹ต(์ง€์‹œ)

                ใ„ด.      ํด๋ผ์ด์–ธํŠธ                ์š”์ฒญ  ->  

          -  ์›น ์„œ๋ฒ„๊ฐ€ ์›น๋ธŒ๋ผ์šฐ์ €์—๊ฒŒ ๋‹ค๋ฅธ ํŽ˜์ด์ง€๋กœ ์ด๋™ํ•˜๋ผ๊ณ  ์‘๋‹ต์„ ํ•˜๋Š” ๊ธฐ๋Šฅ   

-> ํด๋ผ์ด์–ธํŠธ ์›น๋ธŒ๋ผ์šฐ์ € A๊ฐ€ B์—๊ฒŒ ์š”์ฒญ 
-> B๊ฐ€ Cํ•œํ…Œ ์š”์ฒญํ•˜๋ผ๊ณ  ๋งํ•˜๋Š” ์ง€์‹œ๊ฐ€ ๋ฐ”๋กœ ์ผ์–ด๋‚˜์ง€ ์•Š๊ณ 
-> B๊ฐ€ ๋‹ค์‹œ ํด๋ผ์ด์–ธํŠธ์— ๊ฐ”๋‹ค๊ฐ€ ๋‹ค์‹œ C์—๊ฒŒ ์š”์ฒญ (๋ฆฌ๋‹ค์ด๋ ‰ํŠธ)

 

          ์˜ˆ) ex03.jsp                   ์ธ์ฆ ์š”์ฒญ  ->      ex03_ok.jsp 

              ์•„์ด๋””                                                  ํšŒ์›ํ…Œ์ด๋ธ”         /์•„์ด๋””/๋น„๋ฐ€๋ฒˆํ˜ธ ํ™•์ธ

              ๋น„๋ฐ€๋ฒˆํ˜ธ                                               ์ธ์ฆ O -> ์š”์ฒญ ํŽ˜์ด์ง€, ๋ฉ”์ธํŽ˜์ด์ง€ ์ด๋™

                                                                          ์ธ์ฆ X -> ๋กœ๊ทธ์ธ ํŽ˜์ด์ง€ ์ด๋™

              [๋กœ๊ทธ์ธ]    

 

-jsp-

<%
    // ๋กœ๊ทธ์ธ ์„ฑ๊ณต ex03.jsp?id=admin&ok
    // ๋กœ๊ทธ์ธ ์‹คํŒจ ex03.jsp?error
   
    String ok = request.getParameter("ok");
    String error = request.getParameter("error");
    
    if(  ok != null ){  // ๋กœ๊ทธ์ธ ์„ฑ๊ณต
%>
	<script>
	$(function (){
     alert("๋กœ๊ทธ์ธ ์„ฑ๊ณต");
	});
    </script>
<%    
    }else if( error != null ){  // ๋กœ๊ทธ์ธ ์‹คํŒจ
%>
    	<script>
    	 $(function (){
    		 alert("๋กœ๊ทธ์ธ ์‹คํŒจ");
             $(":text").eq(0)
                                 .focus()
                                 .select();
    	 });         
        </script>
  <%     	
    }
%>

- script ํƒœ๊ทธ๋Š” ์„œ๋ฒ„๊ฐ€ ์•„๋‹ˆ๋ผ ์‘๋‹ตํ•˜๋Š” ๋ธŒ๋ผ์šฐ์ €๊ฐ€ ์‹คํ–‰ํ•˜๋Š” ๊ฒƒ์ด๊ธฐ ๋•Œ๋ฌธ์— ํผ์„ผํŠธ ๋ฐ–์— ๋‘ฌ์•ผํ•จ!

- function์œผ๋กœ ๋„ฃ๋Š” ์ด์œ  : form ํƒœ๊ทธ๊ฐ€ ์•„๋ž˜์— ์žˆ๊ธฐ ๋•Œ๋ฌธ์— ์ธ์‹ํ•˜์ง€ ๋ชปํ•จ, function์— ๋„ฃ์–ด์ค˜์•ผํ•จ! 

<form action="ex03_ok.jsp" method="get">
  ์•„์ด๋”” : <input type="text"  name="id"  value="admin"><br>
  ๋น„๋ฐ€๋ฒˆํ˜ธ : <input type="password"  name="passwd"  value="1234"><br>
  <input type="submit"  value="logon"> 
</form>

 

-ok.jsp-

<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%
     String id = request.getParameter("id");
     String passwd = request.getParameter("passwd");
     
     // DB ์—ฐ๋™ ์ฒ˜๋ฆฌ X
     
     String location = "ex03.jsp";
     if(   id.equals("admin") && passwd.equals("1234") ){
    	 // ๋กœ๊ทธ์ธ ์„ฑ๊ณต              : jsp ์ฟ ํ‚ค, ์„ธ์…˜ 
    	 location += "?id="+id+"&ok";
     }else{
    	 // ๋กœ๊ทธ์ธ ์‹คํŒจ
    	 location += "?error";
     }
     
     response.sendRedirect(location);
     // js location.href=location
     
%>

 *์ฃผ์˜ : jsp - ์•„๋ž˜ ํŒŒ๋ผ๋ฏธํ„ฐ ๊ฐ’ ๊ธฐ์–ต

<%
      // ex03_02.jsp                                    param1 = null
      // ex03_02.jsp?error                          param1 = ""
      // ex03_02.jsp?error=404                  param1 = 404
      String param1 =  request.getParameter("error");
      
%>
param1 = <%= param1 %>

 

          ์˜ˆ) ex04.jsp               ex04_ok.jsp

                ๋กœ๊ทธ์ธํ™”๋ฉด๊ตฌ์„ฑ

                ๋กœ๊ทธ์ธ์„ฑ๊ณต ํ™”๋ฉด๊ตฌ์„ฑ

                ๊ฒŒ์‹œํŒ   ๋ฉ”๋‰ด - ๋กœ๊ทธ์ธ O X ๋ชจ๋‘ ์‚ฌ์šฉ

                

                ์„ค๋ฌธ์กฐ์‚ฌ ๋ฉ”๋‰ด   - ๋กœ๊ทธ์ธ O ์‚ฌ์šฉ

                ์ผ์ •๊ด€๋ฆฌ ๋ฉ”๋‰ด

 

-jsp-

	String ok = request.getParameter("ok");
	String error = request.getParameter("error");
<div id="logon">
	<form action="ex04_ok.jsp" method="get">
	  ์•„์ด๋”” : <input type="text"  name="id"  value="admin"><br>
	  ๋น„๋ฐ€๋ฒˆํ˜ธ : <input type="password"  name="passwd"  value="1234"><br>
	  <input type="submit"  value="logon"> 
	</form>
</div>
<div id="logout">
    [${ param.id }]๋‹˜ ๋กœ๊ทธ์ธํ•˜์…จ์Šต๋‹ˆ๋‹ค.<br>
    <button>๋กœ๊ทธ์•„์›ƒ</button>
</div>

<script>
   $("#logout").hide();
</script>

<a href="#">๊ฒŒ์‹œํŒ </a><br>

<%
     if(  ok != null ){  // ๋กœ๊ทธ์ธ ์„ฑ๊ณต
 %>
 <a href="#">์„ค๋ฌธ์กฐ์‚ฌ </a><br>
 <a href="#">์ผ์ •๊ด€๋ฆฌ </a><br>
 <script>
   $(function (){
	   alert("๋กœ๊ทธ์ธ ์„ฑ๊ณต");
	   $("#logon").hide();
	   $("#logout").show();
   });
 </script>
 <%   	 
     }else if( error != null ) {  // ๋กœ๊ทธ์ธ ์‹คํŒจ
 %>
       <script>
    	 $(function (){
    		 alert("๋กœ๊ทธ์ธ ์‹คํŒจ");
             $(":text").eq(0)
                                 .focus()
                                 .select();
    	 });         
        </script>
 <%   	 
     }
%>

 

-ok.jsp-

<%@page import="java.net.URLDecoder"%>
<%@page import="java.net.URLEncoder"%>
<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%
     String id = request.getParameter("id");
     String passwd = request.getParameter("passwd");
     
     // DB ์—ฐ๋™ ์ฒ˜๋ฆฌ X
     
     String location = "ex04.jsp";
     if(   id.equals("admin") && passwd.equals("1234") ){
    	 // ๋กœ๊ทธ์ธ ์„ฑ๊ณต              : jsp ์ฟ ํ‚ค, ์„ธ์…˜ 
    	 
    	 // p 95 ์„ค๋ช…
    	 // ***** ๋ฆฌ๋‹ค์ด๋ ‰ํŠธ ํ•  ๋•Œ ํ•œ๊ธ€ ํŒŒ๋ผ๋ฏธํ„ฐ๊ฐ€ ํฌํ•จ๋˜์–ด ์žˆ๋‹ค๋ฉด 
    	 // ๋ฐ˜๋“œ์‹œ ์ธ์ฝ”๋”ฉ์„ ํ•ด์•ผ ํ•œ๋‹ค. -> ๋””์ฝ”๋”ฉ์„ ํ•ด์•ผ ํ•œ๋‹ค. 
    	 location += "?id="+ URLEncoder.encode( id , "UTF-8" )+"&ok";
    	                               // URLDecoder.decode(s, charset)
     }else{
    	 // ๋กœ๊ทธ์ธ ์‹คํŒจ
    	 location += "?error";
     }
     
     response.sendRedirect(location);
     // js location.href=location
     
%>

   1. ๋ฆฌ๋‹ค์ด๋ ‰ํŠธ( redirect )

   2. ํฌ์›Œ๋”ฉ( forward )                 

   ์ฐจ์ด์ 

   

   ex05.jsp -> ์š”์ฒญ ->

                <- ์‘๋‹ต

                

  a  ๋ฆฌ๋‹ค์ด๋ ‰ํŠธ( redirect )๋งํฌ ํƒœ๊ทธ ํด๋ฆญ     ->       ex05_redirect.jsp?name=admin&age=20  -> ์š”์ฒญ ->  ๋ฆฌ๋‹ค์ด๋ ‰ํŠธ( finish.jsp)

                                                                 <- ์‘๋‹ต     

  ex05_finish.jsp                                  -> ์š”์ฒญ       ?name,age ํŒŒ๋ผ๋ฏธํ„ฐ X                              

                                                             <- ์‘๋‹ต    

 

-jsp-

<%
   String name = "admin";
   int age = 20;
%>
<!-- 
ex05_redirect.jsp?name=admin&age=20
ex05_forward.jsp?name=admin&age=20
 -->
<a href="ex05_redirect.jsp">๋ฆฌ๋‹ค์ด๋ ‰ํŠธ( redirect )</a><br>
<a href="ex05_forward.jsp">ํฌ์›Œ๋”ฉ( forward ) </a><br>

<script>
  $("a").on("click", function (){
	  $(this).attr("href", function (i, val){
		  return val +"?name=<%= name %>&age=<%= age %>";
	  });
  });
</script>

-redirect.jsp-

<%@page import="java.net.URLEncoder"%>
<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
 <!-- 
<h3>ex05_redirect.jsp?name=admin&age=20</h3>
  -->
 <%
     // ์„ธ์…˜, ์ฟ ํ‚ค ์ €์žฅ X
     
    String name = request.getParameter("name");
    String age = request.getParameter("age");
 
     String location = String.format("ex05_finish.jsp?name=%s&age=%s"
    		 , URLEncoder.encode(name, "UTF-8") , age);
     response.sendRedirect(location);
     
     // 1. ์ด์œ  ? finish.jsp        name, age ํŒŒ๋ผ๋ฏธํ„ฐ ์™œ ์ถœ๋ ฅ.
     // 2. ํ•ด๊ฒฐ๋ฐฉ๋ฒ• ? name, age ํŒŒ๋ผ๋ฏธํ„ฐ  ์ถœ๋ ฅ ์ฒ˜๋ฆฌ. 
 
 %>

-forward.jsp-

<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
 <!-- 
<h3>ex05_forward.jsp?name=admin&age=20</h3>
  -->
<%
     // ํฌ์›Œ๋”ฉ( forward )
     String path = "ex05_finish.jsp";
     RequestDispatcher dispatcher = request.getRequestDispatcher(path)  ;
     dispatcher.forward(request, response);
%>

-finish.jsp-

<%@page import="java.net.URLDecoder"%>
<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>2022. 12. 6. ์˜ค์ „ 11:19:45</title>
<link rel="shortcut icon" type="image/x-icon" href="../images/SiSt.ico">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.1/jquery.min.js"></script>
<style>
</style>
</head>
<body>
<h3>ex05_finish.jsp</h3>

<%
      String name = request.getParameter("name");
%>

> name = <%=   URLDecoder.decode(name, "UTF-8") %><br>
> age =  ${ param.age }<br>

<script>
</script>
</body>
</html>

 

* ๋ฆฌ๋‹ค์ด๋ ‰ํŠธ์˜ ๊ฒฝ์šฐ ์›๋ž˜ ํŽ˜์ด์ง€๋กœ ์‘๋‹ตํ•œ ํ›„ ๋‹ค์‹œ ์š”์ฒญ์„ ๋‚ ๋ฆฌ๋Š” ๊ฒƒ์ด๊ธฐ ๋•Œ๋ฌธ์— location๊ฐ’์— ํŒŒ๋ผ๋ฏธํ„ฐ ๋„ฃ์–ด์ค˜์•ผํ•จ!

* ํฌ์›Œ๋”ฉ์˜ ๊ฒฝ์šฐ ์›๋ž˜ ํŽ˜์ด์ง€๋กœ ๋Œ์•„๊ฐ€์ง€ ์•Š๊ณ  ๋ฐ”๋กœ ํŽ˜์ด์ง€ ์ด๋™


    1. ์„œ๋ธ”๋ฆฟ ์‚ฌ์šฉ

    2. a ๋งํฌ(  http://localhost/jspPro/scott/dept )์š”์ฒญ -> ์„œ๋ธ”๋ฆฟ ๊ฐ์ฒด ์š”์ฒญ( ScottDept.java )

         [ get   ๋ฐฉ์‹ ]                                                                     doGet(){} ๊ตฌํ˜„

         post ๋ฐฉ์‹                                                                          doPost(){}  X

         // g + p                                                                                  service(){}

    3.  doGet(){

             // 1.๋ถ€์„œ ์ •๋ณด select ์ฝ”๋”ฉ

             // 2.ArrayList<DeptDTO> list => request ๊ฐ์ฒด ์ €์žฅ 

             // 3. ํฌ์›Œ๋”ฉ  ex06_dept.jsp  ( request [list]) ***   

         }

    

    [๊ธฐ์–ต]

    ํ”„๋กœ์ ํŠธ ํ•  ๋•Œ ๊ฒฝ๋กœ ์„ค์ •ํ•  ๋•Œ ์ƒ๋Œ€๊ฒฝ๋กœ X -> /jspPro/~~  context path(root)  ๊ผญ ์„ค์ •.

    

    ** ์„œ๋ธ”๋ฆฟ url-pattern ์„ค์ • ์ฒดํฌ

 

-jsp-

<a href="<%= contextPath %>/scott/dept">scott.dept(๋ถ€์„œ ์ •๋ณด)</a>

-scottdept.java- (servlet)

package days03;

import java.io.IOException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.util.DBConn;

import domain.DeptDTO;


//@WebServlet("/scott/dept")
public class ScottDept extends HttpServlet {
	private static final long serialVersionUID = 1L;

	public ScottDept() {
		super(); 
	}

	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// 
		// System.out.println("ScottDept.doGet() ํ˜ธ์ถœ๋จ.");
		
		// 1. ArrayList<DeptDTO> list -> request ์ €์žฅ
		String sql = "SELECT deptno, dname, loc "
				+" FROM dept";
		Connection conn =  DBConn.getConnection();
		PreparedStatement pstmt = null;
		ResultSet rs = null;
		ArrayList<DeptDTO> list = null;
		
		try{
			   pstmt = conn.prepareStatement(sql);
			   rs = pstmt.executeQuery();
			   
			   if( rs.next() ){
				   list = new ArrayList<DeptDTO>();
				   do{
					    
					    DeptDTO dto = new DeptDTO(
					    		   rs.getInt("deptno")
					    		   , rs.getString("dname")
					    		   , rs.getString("loc"));
					    
					    list.add(dto);
					    
				   }while( rs.next() );
			   } // if
			   
			   pstmt.close();
			   rs.close();
		   }catch(Exception e){
			   e.printStackTrace();
		   } finally{
			   DBConn.close();
		   } 
		
		request.setAttribute("list", list);

		// 2. ํฌ์›Œ๋”ฉ ex06_dept.jsp

		//  /scott/ex06_dept.jsp
	// String path = "ex06_dept.jsp";  ํŒŒ์ผ๋ช… ์ƒ๋Œ€๊ฒฝ๋กœ
	//  http://localhost/jspPro[/scott/ex06_dept.jsp]
		
		// /jspPro/scott/dept"
		// /jspPro/scott/ex06_dept.jsp"
		 //String path = "/days03/ex06_dept.jsp";  // ์ดํ•ด.
		
		//String path = "/ex06_dept.jsp";  // ์ดํ•ด.
		//http://localhost/jspPro[/ex06_dept.jsp]
		
		// String path = "days03/ex06_dept.jsp";  // ์ดํ•ด.
		//http://localhost/jspPro[/scott/days03/ex06_dept.jsp]
		
		String path = "/days03/ex06_dept_jstl.jsp";  // ์ดํ•ด.
		RequestDispatcher dispatcher = request.getRequestDispatcher(path);
		dispatcher.forward(request, response);
		
		
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doGet(request, response);
	}

}
scott.dept(๋ถ€์„œ ์ •๋ณด) -> ์„œ๋ธ”๋ฆฟ O     ->  ex06_dept.jsp
                               404 X        ํฌ์›Œ๋”ฉ   404

-dept.jsp-

<%@page import="java.util.Iterator"%>
<%@page import="domain.DeptDTO"%>
<%@page import="java.util.ArrayList"%>
<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%
       String contextPath = request.getContextPath();
%>
<%
     // ํŒŒ๋ผ๋ฏธํ„ฐ : request.getParameter(name)
     // request.setAttribute("list", list);
     ArrayList<DeptDTO> list =  (ArrayList<DeptDTO>)request.getAttribute("list");
%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>2022. 12. 6. ์˜คํ›„ 12:12:23</title>
<link rel="shortcut icon" type="image/x-icon" href="../images/SiSt.ico">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.1/jquery.min.js"></script>
<style>
</style>
</head>
<body>
<h3>ex06_dept.jsp</h3>

<p>.</p>
<p>.</p>

<select id="selDept" name="deptno">
   <option>์„ ํƒ...</option>
<%
    if(  list != null ){   // ๋ถ€์„œ๊ฐ€ ์กด์žฌํ•œ๋‹ค. 
    	
    	Iterator<DeptDTO>  ir = list.iterator();
        while(   ir.hasNext() ){
            DeptDTO dto =  ir.next();
%>
   <option value="<%= dto.getDeptno() %>"><%= dto.getDname() %></option>
<%            
        } // while
    }else{  // 1๊ฐœ์˜ ๋ถ€์„œ๋„ ์กด์žฌํ•˜์ง€ ์•Š๋Š”๋‹ค. 
%>
   <option> 1๊ฐœ์˜ ๋ถ€์„œ๋„ ์กด์žฌํ•˜์ง€ ์•Š๋Š”๋‹ค. </option>
<%    	
    }
%>  		
</select>

<script>
  $("#selDept")
         .wrap("<form></form>")
         .change( function (){
	             $(this)
	                  .parent()    // form
	                       .attr({      //      /jspPro
	                    	   action: "<%= contextPath %>/scott/emp" ,
	                    	   method: "get"
	                       })
	                       .submit();
         });
</script>

<script>
</script>
</body>
</html>

  1. select  ํƒœ๊ทธ์—์„œ ํ•˜๋‚˜์˜ ๋ถ€์„œ(option)๋ฅผ ์„ ํƒ

     -> ์„œ๋ธŒ๋ฐ‹(submit)

     http://localhost/jspPro[/scott/emp]   GET ๋ฐฉ์‹  +  ์„ ํƒํ•œ ๋ถ€์„œ๋ฒˆํ˜ธ(deptno = 20)

     

    jquery ์‚ฌ์šฉ.

     

  2. ์„œ๋ธ”๋ฆฟ(ScottEmp.java) ์š”์ฒญ - doGet() {  ์ฝ”๋”ฉ}

    

  3.   ์„œ๋ธ”๋ฆฟ(ScottEmp.java) doGet(){

        pdeptno = 20;

        ArrayList<EmpDTO> list ;

        request ์ €์žฅ

        ํฌ์›Œ๋”ฉ  ex06_emp.jsp

    4. ex06_emp.jsp

        ํ…Œ์ด๋ธ”         ArrayList<EmpDTO> list ;

        ์ถœ๋ ฅ.

  }

 

-scottEmp.java-

package days03;

import java.io.IOException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;  // Ctrl + Shift + O

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.util.DBConn;

import domain.DeptDTO;
import domain.EmpDTO;
 
// @WebServlet("/scott/emp")
public class ScottEmp extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    public ScottEmp() {
        super(); 
    }
 
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// System.out.println("ScottEmp.doGet() ํ˜ธ์ถœ๋จ.");
		int pdeptno = 10;
	     try{
	    	 pdeptno =  Integer.parseInt( request.getParameter("deptno") );
	     }catch(NumberFormatException e){  }
	     //
	 
	    Connection conn  = DBConn.getConnection();
	    PreparedStatement  pstmt = null;
	    ResultSet rs = null; 
	    	    
	    // 1. ๋ถ€์„œ ์ •๋ณด X
	    // 2. ํ•ด๋‹น ๋ถ€์„œ์› ์ •๋ณด  
	    ArrayList<EmpDTO> empList = null;
	    String sql =      "SELECT * "
					           +" FROM emp "
					           +" WHERE deptno = ? "
					           +" ORDER BY ename ASC";
	     
	    		
	    try{
	    	 pstmt =  conn.prepareStatement(sql);
	    	 pstmt.setInt(1,  pdeptno );
	    	 rs =  pstmt.executeQuery();
	    	 
	    	 if( rs.next() ){
	    		empList = new ArrayList<>();
	    		do{
	    			//  empno,  ename,  job,  hiredate,  mgr,  sal,  comm,  deptno  
	    			EmpDTO dto = new EmpDTO(
	    					rs.getInt("empno")
	    					, rs.getString("ename")
	    					, rs.getString("job")
	    					, rs.getDate("hiredate")
	    					, rs.getInt("mgr")
	    					, rs.getDouble("sal")
	    					, rs.getDouble("comm")
	    					, rs.getInt("deptno")
	    					);
	        		empList.add(dto);
	    		}while( rs.next() );
	    	 } // if
	    	 
	    	 pstmt.close();
	    	 rs.close(); 
	   }catch(Exception e){
	   	e.printStackTrace();
	   } // try	    
	    DBConn.close();
	    
	    // 1. request ์ €์žฅ
	    request.setAttribute("empList", empList);
	    // 2. ํฌ์›Œ๋”ฉ
	    //String path = "/days03/ex06_emp.jsp";
	    String path = "/days03/ex06_emp_jstl.jsp";
	    RequestDispatcher dispatcher = request.getRequestDispatcher(path);
	    dispatcher.forward(request, response);
	    
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doGet(request, response);
	}

}

 

-emp.jsp-

<%@page import="java.util.Iterator"%>
<%@page import="domain.EmpDTO"%>
<%@page import="java.util.ArrayList"%>
<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%
   String contextPath = request.getContextPath();
%>
<%
     // request.setAttribute("empList", empList);
     ArrayList<EmpDTO> empList =  (ArrayList<EmpDTO>)request.getAttribute("empList");
%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>2022. 12. 6. ์˜คํ›„ 2:47:59</title>
<link rel="shortcut icon" type="image/x-icon" href="../images/SiSt.ico">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.1/jquery.min.js"></script>
<style>

 table{
   width:100%;
   min-width: 700px;
 }
 
 table, th, td{
   border:1px solid gray;
 }

</style>
</head>
<body>
<h3>ex06_emp.jsp</h3>
<br>
<br>
<table>
  <thead>
    <tr>
     <th><input type="checkbox" id="ckbAll" name="ckbAll">์ „์ฒด ์„ ํƒ</th>
     <th>empno</th>
     <th>ename</th>
     <th>job</th>
     <th>hiredate</th>
     <th>mgr</th>
     <th>sal</th>
     <th>comm</th>
     <th>deptno</th>
    </tr>
  </thead>
  <tbody>
<%
     if( empList != null ){  // ์‚ฌ์› ์กด์žฌ O
    	 Iterator<EmpDTO> ir2 = empList.iterator();
    	 while( ir2.hasNext() ){
    		 EmpDTO dto = ir2.next();
%>
        <tr>
           <!-- <td><input type="checkbox"  name="ckbEmp"  data-์†์„ฑ๋ช…="์†์„ฑ๊ฐ’" data-์†์„ฑ๋ช…="์†์„ฑ๊ฐ’"></td> -->
           <td><input type="checkbox"  name="ckbEmp"  data-empno="<%= dto.getEmpno() %>"></td>
           <td><%= dto.getEmpno() %></td>
           <td><%= dto.getEname() %></td>
           <td><%= dto.getJob() %></td>
           <td><%= dto.getHiredate() %></td>
           <td><%= dto.getMgr() %></td>
           <td><%= dto.getSal() %></td>
           <td><%= dto.getComm() %></td>
           <td><%= dto.getDeptno() %></td>
        </tr>
<%    		 
    	 } // while
     }else{ // ์‚ฌ์› ์กด์žฌ X
%>
     <tr>
        <td colspan="9"  style="text-align: center">employee does not exist.</td>
     </tr>
<%    	 
     } // if
%>
  </tbody>
  <tfoot>
    <tr>
       <td colspan="9"  style="text-align: center">
          <button id="checkedEmpno">์„ ํƒํ•œ empno ํ™•์ธ</button>
       </td>
    </tr>
  </tfoot>
</table>


<a href="<%= contextPath %>/scott/dept">๋‹ค์‹œํ•˜๊ธฐ</a>

   [ JSTL ]  p 292    Chapter 12 ํ‘œ์ค€ ํƒœ๊ทธ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ (JSTL)

   1.  ex06_dept.jsp      /  ex06_emp.jsp ์ฝ”๋”ฉ ์ˆ˜์ • 

       ex06_dept_jstl.jsp / ex06_emp_jstl.jsp  ๋ณต์‚ฌ ,  ๋ถ™์ด๊ธฐ.

       

   2. JSTL    

     - ์ปค์Šคํ…€ ํƒœ๊ทธ

        jsp:~~~> ์•ก์…˜ํƒœ๊ทธ์™€ ๊ฐ™์ด 

        ๊ฐœ๋ฐœ์ž ํ•„์š”์— ์˜ํ•ด์„œ ํƒœ๊ทธ ์ •์˜ํ•ด์„œ ์‚ฌ์šฉํ•œ๋‹ค. 

     -  ์—ฌ๋Ÿฌ ๊ฐœ๋ฐœ์ž๊ฐ€ ๊ณตํ†ต์ ์œผ๋กœ ์ปค์Šคํ…€ ํƒœ๊ทธ๋ฅผ ๋งŒ๋“ค๊ธฐ์— ์ด๊ฒƒ์„ ํ‘œ์ค€ํ™”์‹œํ‚จ ํƒœ๊ทธ๊ฐ€

        JSP Standard Tag Library( JSTL)

     -    ๋ณ€์ˆ˜ ์„ ์–ธ + ํƒœ๊ทธ, ํ•จ์ˆ˜ , ์ œ์–ด๋ฌธ ํƒœ๊ทธ, URL ์ฒ˜๋ฆฌ + ํƒœ๊ทธ, ์ถœ๋ ฅ ํƒœ๊ทธ ๋“ฑ๋“ฑ 

     - p 294  ํ‘œ 12.1   JSTL ํƒœ๊ทธ์˜  5๊ฐ€์ง€  ์ข…๋ฅ˜

         ***  1) ์ฝ”์–ด        : ๋ณ€์ˆ˜, ์ œ์–ด๋ฌธ, URL ์ฒ˜๋ฆฌ ํƒœ๊ทธ  :  ์ ‘๋‘์–ด( c ) :  http://java.sun.com/jsp/jstl/core

        2) XML

        3) ๊ตญ์ œํ™”

        4) ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค

        5) ํ•จ์ˆ˜

     - JSTL ์‚ฌ์šฉํ•˜๋ ค๋ฉด    jstl-1.2.jar ๋‹ค์šด๋กœ๋“œ 

     

     JAVA+ JSP + Spring ํ•„์š”ํ•œ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ 

     https://mvnrepository.com/

     

web-inf ํด๋”์— ์œ„ ๋งํฌ์—์„œ jstl 1.2๋‹ค์šด (usages ๋งŽ์€๊ฑฐ), ojdbc๋„ ๋ฐ›์•„์„œ ์—ฌ๊ธฐ ๋„ฃ์–ด์•ผํ•จ!

 

 

<%@ taglib prefix="c"  uri="http://java.sun.com/jsp/jstl/core" %>

dept.jstl

<%@page import="java.util.Iterator"%>
<%@page import="domain.DeptDTO"%>
<%@page import="java.util.ArrayList"%>
<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c"  uri="http://java.sun.com/jsp/jstl/core" %>

<%
       String contextPath = request.getContextPath();
%>
<% 
     // request.setAttribute("list ์†์„ฑ๋ช…", list);
%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>2022. 12. 6. ์˜คํ›„ 12:12:23</title>
<link rel="shortcut icon" type="image/x-icon" href="../images/SiSt.ico">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.1/jquery.min.js"></script>
<style>
</style>
</head>
<body>
<h3>ex06_dept_jstl.jsp</h3>

<p>.</p>
<p>.</p>

<select id="selDept" name="deptno">
   <option>์„ ํƒ...</option>   
   
   <c:if test="${ not empty list }">
      <c:forEach items="${ list }"  var="dto">
         <option value="${ dto.deptno  }">${ dto.dname }</option>
      </c:forEach>
   </c:if>
   <c:if test="${ empty list }">
       <option> 1๊ฐœ์˜ ๋ถ€์„œ๋„ ์กด์žฌํ•˜์ง€ ์•Š๋Š”๋‹ค. </option>
   </c:if> 
 
</select>

<script>
  $("#selDept")
         .wrap("<form></form>")
         .change( function (){
	             $(this)
	                  .parent()    // form
	                       .attr({      //      /jspPro
	                    	   action: "<%= contextPath %>/scott/emp" ,
	                    	   method: "get"
	                       })
	                       .submit();
         });
</script>

emp.jstl

<%@page import="java.util.Iterator"%>
<%@page import="domain.EmpDTO"%>
<%@page import="java.util.ArrayList"%>
<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c"  uri="http://java.sun.com/jsp/jstl/core" %>

<%
   String contextPath = request.getContextPath();   // EL  
%>

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>2022. 12. 6. ์˜คํ›„ 2:47:59</title>
<link rel="shortcut icon" type="image/x-icon" href="../images/SiSt.ico">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.1/jquery.min.js"></script>
<style>

 table{
   width:100%;
   min-width: 700px;
 }
 
 table, th, td{
   border:1px solid gray;
 }

</style>
</head>
<body>
<h3>ex06_emp_jstl.jsp</h3>
<br>
<br>
<table>
  <thead>
    <tr>
     <th><input type="checkbox" id="ckbAll" name="ckbAll">์ „์ฒด ์„ ํƒ</th>
     <th>empno</th>
     <th>ename</th>
     <th>job</th>
     <th>hiredate</th>
     <th>mgr</th>
     <th>sal</th>
     <th>comm</th>
     <th>deptno</th>
    </tr>
  </thead>
  <tbody>
  
  <c:if test="${ not empty empList }">
     <c:forEach items="${ empList }" var="dto">
         <tr>
           <!-- <td><input type="checkbox"  name="ckbEmp"  data-์†์„ฑ๋ช…="์†์„ฑ๊ฐ’" data-์†์„ฑ๋ช…="์†์„ฑ๊ฐ’"></td> -->
           <td><input type="checkbox"  name="ckbEmp"  data-empno="${ dto.empno }"></td>
           <td>${ dto.empno }</td>
           <td>${ dto.ename }</td>
           <td>${ dto.job }</td>
           <td>${ dto.hiredate }</td>
           <td>${ dto.mgr }</td>
           <td>${ dto.sal }</td>
           <!-- .PropertyNotFoundException: [com] ํŠน์„ฑ์ด [domain.EmpDTO] ์œ ํ˜• -->
           <td>${ dto.comm }</td>
           <td>${ dto.deptno }</td>
        </tr>
     </c:forEach>
  </c:if>
  <c:if test="${ empty empList }">
     <tr>
        <td colspan="9"  style="text-align: center">employee does not exist.</td>
     </tr>
  </c:if>

  </tbody>
  <tfoot>
    <tr>
       <td colspan="9"  style="text-align: center">
          <button id="checkedEmpno">์„ ํƒํ•œ empno ํ™•์ธ</button>
       </td>
    </tr>
  </tfoot>
</table>


<a href="<%= contextPath %>/scott/dept">๋‹ค์‹œํ•˜๊ธฐ</a>

    ex07.jsp ํŽ˜์ด์ง€์—์„œ     

    form   get      -> Member.java ( doGet(){})    

    form   post    -> Member.java( doPost(){} )

*๊ฐ™์€ ๋ฐ์ดํ„ฐ ๋‚ ๋ ธ์„ ๋•Œ Member.java๋ผ๋Š” ์„œ๋ธ”๋ฆฟ ๋งŒ๋“œ๋Š”๋ฐ ๊ฐ๊ฐ ๋‹ค๋ฅด๊ฒŒ ์ฒ˜๋ฆฌ 

 

-jsp-

<%
    String contextPath = request.getContextPath();
%>

<form action="<%= contextPath %>/member/get" method="get">
name : <input type="text" name="name" value="ํ™๊ธธ๋™"><br> 
age :  <input type="text" name="age" value="20"><br>
<input type="submit"  value="GET ์ „์†ก">
</form>

<form action="<%= contextPath %>/member/post" method="post">
name : <input type="text" name="name" value="ํ™๊ธธ๋™"><br> 
age :  <input type="text" name="age" value="20"><br>
<input type="button"  value="POST ์ „์†ก">
</form>

<script>
  $("form:last-of-type :button").on("click", function (){
	  // ์ž…๋ ฅ๊ฐ’์— ๋Œ€ํ•œ ์œ ํšจ์„ฑ ๊ฒ€์‚ฌ ํ•œ ํ›„
	  // $(this).parent();
	  $(this).parents("form").submit();
  });
</script>

 

-Member.java-

package days03;

import java.io.IOException;
import java.net.URLEncoder;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

// ํ•˜๋‚˜์˜ ์„œ๋ธ”๋ฆฟ Member ๊ฐ€์ง€๊ณ 
// doGet() ๋”ฐ๋กœ ์ฒ˜๋ฆฌ
// doPost() ๋”ฐ๋กœ ์ฒ˜๋ฆฌ..
@WebServlet({ "/member/get", "/member/post" })
public class Member extends HttpServlet {
	private static final long serialVersionUID = 1L;
      
    public Member() {
        super(); 
    }

    //    /member/get  + get
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		
		String name = request.getParameter("name");
		String age = request.getParameter("age");
		
		// ๋ฆฌ๋‹ค์ด๋ ‰ํŠธ  
		// (์ฃผ์˜) ํ•œ๊ธ€ ์ธ๊ฒฝ์šฐ ์ธ์ฝ”๋”ฉ. 
		String location = String.format(
				"/jspPro/days03/ex07_ok.jsp?name=%s&age=%s"
				,  URLEncoder.encode( name , "UTF-8" )
				, age );
		response.sendRedirect(location);
	}
 
	//     /member/post  + post
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		request.setCharacterEncoding("UTF-8");
		
		String name = request.getParameter("name");
		System.out.println(  name );
		
		 // ํฌ์›Œ๋”ฉ. 
		 String path = "/days03/ex07_ok.jsp";
		 RequestDispatcher dispatcher = request.getRequestDispatcher(path);
		 dispatcher.forward(request, response);
	}

}

* ๋ฆฌ๋‹ค์ด๋ ‰ํŠธ์˜ ๊ฒฝ์šฐ /jspPro ๋ถ€ํ„ฐ ์‹œ์ž‘ํ•ด์•ผํ•จ!

 

-ok.jsp-

<%
   String name = request.getParameter("name");
%>
> Member ์„œ๋ธ”๋ฆฟ :  name =  <%= name %><br>
> Member ์„œ๋ธ”๋ฆฟ :  age =  ${ param.age }<br>

<br><br>
<a href="ex07.jsp">๋‹ค์‹œํ•˜๊ธฐ</a>

 

๊ฒฐ๊ณผ)

- get ๋ฆฌ๋‹ค์ด๋ ‰ํŠธ์˜ ๊ฒฝ์šฐ ํŒŒ๋ผ๋ฏธํ„ฐ ๋„˜์–ด๊ฐ€์ง€ ์•Š์•„์„œ URL์— ๋„ฃ์–ด์ฃผ๋Š” ๋ฐฉ์‹์œผ๋กœ 

- get์€ ๋‹ค์‹œํ•˜๊ธฐ ๊ฐ€๋Šฅ -> url์ด ์ž˜ ์žกํž˜

- post๋Š” ํ•œ๊ธ€ ๊นจ์ง€๊ณ 

- post ๋‹ค์‹œํ•˜๊ธฐ ๋ˆ„๋ฅด๋ฉด 404์—๋Ÿฌ -> url ์ด member๋กœ ์žกํž˜ 

 


   ex08.jsp    -> ex08_02.jsp  -> ex08_03.jsp

   ์ด๋ฆ„                  ์ฃผ์†Œ

   ๋‚˜์ด                  ์—ฐ๋ฝ์ฒ˜

   

   ์„œ๋ธŒ๋ฐ‹                 ์„œ๋ธŒ๋ฐ‹

 

-1.jsp-

<form action="ex08_02.jsp"  method="get">
  name : <input type="text" name="name" value="ํ™๊ธธ๋™"><br> 
  age : <input type="text" name="age" value="20"><br>
  
  <input type="submit"  value="Next">
</form>

-2.jsp-

<form action="ex08_03.jsp"  method="get">
  address : <input type="text" name="address" value="์„œ์šธ ์—ญ์‚ผ๋™"><br> 
  tel : <input type="text" name="tel" value="010-1234-1234"><br>
  <input type="button" value="Prev" onclick="history.back()">
  <input type="submit"  value="Next">
</form>

-3.jsp-

  • ๋„ค์ด๋ฒ„ ๋ธ”๋Ÿฌ๊ทธ ๊ณต์œ ํ•˜๊ธฐ
  • ๋„ค์ด๋ฒ„ ๋ฐด๋“œ์— ๊ณต์œ ํ•˜๊ธฐ
  • ํŽ˜์ด์Šค๋ถ ๊ณต์œ ํ•˜๊ธฐ
  • ์นด์นด์˜ค์Šคํ† ๋ฆฌ ๊ณต์œ ํ•˜๊ธฐ