[๊ตฌ๋””์•„์นด๋ฐ๋ฏธ IT๊ตญ๋น„์ง€์›] ๊ทธ๋™์•ˆ ๋ฐฐ์šด ๊ธฐ๋Šฅ์œผ๋กœ ์ตœ์ข…์ ์œผ๋กœ ๋‹ค์‹œ ํ•œ๋ฒˆ action ํŽ˜์ด์ง€๋ฅผ ๋งŒ๋“ค์–ด๋ณด๊ณ , ์ž๋ฐ”์˜ ๊ธฐ๋ณธํƒ€์ž…, Stringํƒ€์ž…๊ณผ ์—ฐ์‚ฐ์ž์— ๋Œ€ํ•ด์„œ ๊ฐ„๋‹จํ•˜๊ฒŒ ๋ฐฐ์› ๋‹ค.


๐Ÿ’ก์ž๋ฐ” ์•ฑ ํ”„๋กœ๊ทธ๋žจ&์›น ํ”„๋กœ๊ทธ๋žจ

  • ์•ฑ : class๋ฅผ ๋งŒ๋“ค๊ณ  ๋ฉ”์ธ๋ฉ”์†Œ๋“œ๋ฅผ ๋งŒ๋“ค์–ด์„œ ๊ทธ ์•ˆ์— ์ฝ”๋“œ๋ฅผ ๊ตฌํ˜„ํ•œ๋‹ค. java project๋ฅผ ์ƒ์„ฑํ•˜์—ฌ ๋งŒ๋“ ๋‹ค.
  • ์›น : ํ†ฐ์บฃ(was)๋ฅผ ์„ค์น˜ํ•ด์•ผํ•˜๊ณ , ๊ธฐ๋ณธ์ ์œผ๋กœ html์— ๋Œ€ํ•ด ์•Œ์•„์•ผํ•œ๋‹ค. dynamic web project๋ฅผ ์ƒ์„ฑํ•˜์—ฌ ๋งŒ๋“ ๋‹ค. (java EE)

์šฐ๋ฆฌ๋Š” ๋จผ์ € ์›นํ”„๋กœ๊ทธ๋žจ ํ˜•ํƒœ๋กœ ๋ฐฐ์šฐ๋‹ค๊ฐ€ ์•ฑ ํ˜•ํƒœ๋กœ ๋„˜์–ด๊ฐ€์„œ ํด๋ž˜์Šค์™€ ๋ฉ”์†Œ๋“œ๋ฅผ ๋ฐฐ์šธ ๊ฒƒ์ด๋‹ค.
์™œ๋ƒ๋ฉด ์•ฑ์€ ๋ฐ˜๋“œ์‹œ ์ž๋ฐ”์ผ ํ•„์š”๊ฐ€ ์—†์ง€๋งŒ ์›น์€ 70% ์ด์ƒ์ด ์ž๋ฐ”๋กœ ๋งŒ๋“ค๊ธฐ ๋•Œ๋ฌธ!

๐Ÿ“java project

์ž๋ฐ”์˜ ๋ฒ„์ „์„ ๊ผญ ํ™•์ธํ•ด์•ผ ํ•œ๋‹ค.

perspective๋ฅผ ๊ฐœ๋ฐœํ™˜๊ฒฝ์— ๋งž๊ฒŒ ๋ฐ”๊ฟ”์ฃผ๋ฉด ์ข‹๋‹ค.

java ํ”„๋กœ์ ํŠธ ๋‚ด์—์„œ class ํŒŒ์ผ์„ ์ƒ์„ฑํ•  ๋•Œ์—๋Š” ํŒจํ‚ค์ง€๋ฅผ ์ง€์šด๋‹ค.

๐Ÿ“๋น„๊ต


์กฐ๊ธˆ์˜ ๋ฐฉ๋ฒ•์˜ ์ฐจ์ด๊ฐ€ ์žˆ์ง€๋งŒ ์ถœ๋ ฅ์€ ๋˜‘๊ฐ™์€ ๊ฒƒ์„ ๋ณผ ์ˆ˜ ์žˆ๋‹ค.

๐Ÿ’กaction ํŽ˜์ด์ง€ ๋งŒ๋“ค๊ธฐ

์ง€๊ธˆ๊นŒ์ง€ ๋ฐฐ์šด ๋‚ด์šฉ์œผ๋กœ ์˜ˆ์ œ๋ฅผ ๋ณด๊ณ  ๋˜‘๊ฐ™์ด ํŽ˜์ด์ง€ ์นดํ”ผํ•˜์—ฌ action ํŽ˜์ด์ง€๋ฅผ ๋งŒ๋“œ๋Š” ์‹œ๊ฐ„์„ ๊ฐ€์กŒ๋‹ค.

๐Ÿ“์˜ˆ์ œ

๐Ÿ“์ž‘์„ฑ (1) - resume.html

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>resume</title>
<style>
   table, th, td {
      border: 1px solid #000000;
   }
   table {
      width: 100%;
      border-collapse: collapse;
   }
   .centertext {text-align: center;}
   .boldtext {font-weight: bold;}
   .pinkcell {background-color: #FFD9EC;}
   .width80 {width: 80%;}
   .width10 {width: 10%;}
   .border0 {border: 0px solid #FFFFFF;}
</style>
</head>
<body>
   <h1 class="centertext">์ž…์‚ฌ์ง€์›์„œ</h1>
   <form method="post" action="./resumeAction.jsp">
      <!-- ํ…Œ์ด๋ธ”1 -->
      <table>
         <tr><!-- 1ํ–‰ -->
            <td rowspan="6">
               <input type="file" name="pic">
            </td>
            <td rowspan="2" class="centertext boldtext pinkcell">์„ฑ๋ช…</td>
            <td class="centertext boldtext pinkcell">ํ•œ๊ธ€</td>
            <td class="centertext">
            	<input type="text" name="name">
            </td>
            <td class="centertext boldtext pinkcell">์ง€์›๋ถ€๋ถ„</td>
            <td class="centertext">
            	<input type="text">
            </td>
         </tr>
         <tr><!-- 2ํ–‰ -->
            <!-- <td></td> -->
            <!-- <td></td> -->
            <td class="centertext boldtext pinkcell">์˜๋ฌธ</td>
            <td class="centertext">
            	<input type="text">
            </td>
            <td class="centertext boldtext pinkcell">์ง€์›๊ตฌ๋ถ„</td>
            <td class="centertext">
            	<input type="text">
            </td>
         </tr>
         <tr><!-- 3ํ–‰ -->
            <!-- <td></td> -->
            <td class="centertext boldtext pinkcell">์ƒ๋…„์›”์ผ</td>
            <td colspan="2" class="centertext">
            	<input type="date">
            	<select>
            		<option>์„ฑ๋ณ„</option>
            		<option>๋‚จ</option>
            		<option>์—ฌ</option>
            	</select>
            </td>
           <!-- <td></td> -->
            <td class="centertext boldtext pinkcell">์‹ ์ž…/๊ฒฝ๋ ฅ</td>
            <td class="centertext">
            	<input type="radio" name="career">์‹ ์ž…
            	<input type="radio" name="career">๊ฒฝ๋ ฅ
            </td>
         </tr>
         <tr><!-- 4ํ–‰ -->
            <!-- <td></td> -->
            <td class="centertext boldtext pinkcell">ํœด๋Œ€ํฐ</td>
            <td colspan="4" class="centertext">
            	010 - 
            	<input type="text" class="width10"> - <input type="text" class="width10">
            </td>
            <!-- <td></td>
            <td></td>
            <td></td> -->
         </tr>
         <tr><!-- 5ํ–‰ -->
            <!-- <td></td> -->
            <td class="centertext boldtext pinkcell">ํ˜„์ฃผ์†Œ</td>
            <td colspan="4" class="centertext">
            	<input type="text" class="width80">
            </td>
         	<!-- <td></td>
            <td></td>
            <td></td> -->
         </tr>
         <tr><!-- 6ํ–‰ -->
            <!-- <td></td> -->
            <td class="centertext boldtext pinkcell">๊ธด๊ธ‰์—ฐ๋ฝ์ฒ˜</td>
            <td colspan="2" class="centertext">
            	010 - 
            	<input type="text" class="width10"> - <input type="text" class="width10">
            </td>
            <!-- <td></td> -->
            <td class="centertext boldtext pinkcell">๊ด€๊ณ„</td>
            <td class="centertext">
            	<input type="text">
            </td>
         </tr>
      </table>
      
      <h2>&#9830; ํ•™๋ ฅ์‚ฌํ•ญ</h2>
      <!-- ํ…Œ์ด๋ธ” 2 -->
      <table>
      	<tr><!-- 1ํ–‰ -->
      		<td class="centertext boldtext pinkcell">์กธ์—…์ผ</td>
      		<td class="centertext boldtext pinkcell">ํ•™๊ต๋ช…</td>
      		<td class="centertext boldtext pinkcell">์ „๊ณต</td>
      		<td class="centertext boldtext pinkcell">์กธ์—…์—ฌ๋ถ€</td>
      		<td class="centertext boldtext pinkcell">๋น„๊ณ </td>
      	</tr>
      	<tr><!-- 2ํ–‰ -->
      		<td class="centertext">
      			<input type="date">
      		</td>
      		<td class="centertext">
            	<input type="text" placeholder="๊ณ ๋“ฑํ•™๊ต" style="text-align:right">
            </td>
      		<td class="centertext">
            	<input type="text">
            </td>
      		<td class="centertext">
            	<input type="radio" name="g">์žฌํ•™
            	<input type="radio" name="g">์กธ์—…
            </td>
      		<td class="centertext">
            	<input type="text">
            </td>
      	</tr>
      	<tr><!-- 3ํ–‰ -->
      		<td class="centertext">
      			<input type="date">
      		</td>
      		<td class="centertext">
            	<input type="text" placeholder="๋Œ€ํ•™" style="text-align:right">
            </td>
      		<td class="centertext">
            	<input type="text">
            </td>
      		<td class="centertext">
            	<input type="radio" name="g">์žฌํ•™
            	<input type="radio" name="g">์กธ์—…
            </td>
      		<td class="centertext">
            	<input type="text">
            </td>
      	</tr>
      	<tr><!-- 4ํ–‰ -->
      		<td class="centertext">
      			<input type="date">
      		</td>
      		<td class="centertext">
            	<input type="text">
            </td>
      		<td class="centertext">
            	<input type="text">
            </td>
      		<td class="centertext">
            	<input type="radio" name="g">์žฌํ•™
            	<input type="radio" name="g">์กธ์—…
            </td>
      		<td class="centertext">
            	<input type="text">
            </td>
      	</tr>
      </table>
      
      <h2>&#9830; ๊ฒฝ๋ ฅ์‚ฌํ•ญ</h2>
      <!-- ํ…Œ์ด๋ธ” 3 -->
      <table>
      	<tr><!-- 1ํ–‰ -->
      		<td class="centertext boldtext pinkcell">๊ทผ๋ฌด๊ธฐ๊ฐ„</td>
      		<td class="centertext boldtext pinkcell">ํšŒ์‚ฌ๋ช…</td>
      		<td class="centertext boldtext pinkcell">์ตœ์ข…์ง์œ„</td>
      		<td class="centertext boldtext pinkcell">๋‹ด๋‹น์—…๋ฌด</td>
      		<td class="centertext boldtext pinkcell">ํ‡ด์‚ฌ์‚ฌ์œ </td>
      	</tr>
      	<tr><!-- 2ํ–‰ -->
      		<td class="centertext">
      			<input type="date"> ~ <input type="date">
      		</td>
      		<td class="centertext">
            	<input type="text">
            </td>
      		<td class="centertext">
            	<input type="text">
            </td>
      		<td class="centertext">
            	<input type="text">
            </td>
      		<td class="centertext">
            	<input type="text" placeholder="์ด์ง" class="centertext">
            </td>
      	</tr>
      	<tr><!-- 3ํ–‰ -->
      		<td class="centertext">
      			<input type="date">  ~ <input type="date">
      		</td>
      		<td class="centertext">
            	<input type="text">
            </td>
      		<td class="centertext">
            	<input type="text">
            </td>
      		<td class="centertext">
            	<input type="text">
            </td>
      		<td class="centertext">
            	<input type="text">
            </td>
      	</tr>
      	<tr><!-- 4ํ–‰ -->
      		<td class="centertext">
      			<input type="date">  ~ <input type="date">
      		</td>
      		<td class="centertext">
            	<input type="text">
            </td>
      		<td class="centertext">
            	<input type="text">
            </td>
      		<td class="centertext">
            	<input type="text">
            </td>
      		<td class="centertext">
            	<input type="text">
            </td>
      	</tr>
      	<tr><!-- 5ํ–‰ -->
      		<td class="centertext">
            	<input type="date">  ~ <input type="date">
            </td>
            <td class="centertext">
            	<input type="text">
            </td>
            <td class="centertext">
            	<input type="text">
            </td>
            <td class="centertext">
            	<input type="text">
            </td>
            <td class="centertext">
            	<input type="text">
            </td>
      	</tr>
      	<tr><!-- 6ํ–‰ -->
      		<td class="centertext">
            	<input type="date">  ~ <input type="date">
            </td>
            <td class="centertext">
            	<input type="text">
            </td>
            <td class="centertext">
            	<input type="text">
            </td>
            <td class="centertext">
            	<input type="text">
            </td>
            <td class="centertext">
            	<input type="text">
            </td>
      	</tr>
      </table>
      
      <h2>&#9830; ์‹ ์ฒด์‚ฌํ•ญ(์œ ๋‹ˆํผ์‚ฌ์ด์ฆˆ)</h2>
      <!-- ํ…Œ์ด๋ธ” 4 -->
      <table>
      	<tr><!-- 1ํ–‰ -->
      		<td class="centertext boldtext pinkcell">์‹ ์žฅ</td>
      		<td class="centertext">
      			<input type="number"> cm
      		</td>
      		<td class="centertext boldtext pinkcell">์ฒด์ค‘</td>
      		<td class="centertext">
      			<input type="number"> kg
      		</td>
      		<td class="centertext boldtext pinkcell">์‹ ๋ฐœ</td>
      		<td class="centertext">
      			<input type="number"> mm
      		</td>
      	</tr>
      	<tr><!-- 2ํ–‰ -->
      		<td class="centertext boldtext pinkcell">์‹œ๋ ฅ</td>
      		<td class="centertext">
      			<input type="text" class="width10"> / <input type="text" class="width10">
      		</td>
      		<td class="centertext boldtext pinkcell">์ƒ์˜</td>
      		<td class="centertext">
      			<input type="text">
      		</td>
      		<td class="centertext boldtext pinkcell">ํ•˜์˜</td>
      		<td class="centertext">
      			<input type="text">
      		</td>
      	</tr>
      </table>
      
      <h2>&#9830; ๋ณ‘์—ญ์‚ฌํ•ญ</h2>
      <!-- ํ…Œ์ด๋ธ” 5 -->
      <table>
      	<tr><!-- 1ํ–‰ -->
      		<td class="centertext boldtext pinkcell">๊ตฐํ•„์—ฌ๋ถ€</td>
      		<td colspan="5" class="centertext width90">
      			<input type="radio" name="m">๊ตฐํ•„
      			<input type="radio" name="m">๋ฏธํ•„
      			<input type="radio" name="m">๋ฉด์ œ
      			<input type="radio" name="m">๊ธฐํƒ€
      			<input type="radio" name="m">ํ•ด๋‹น์—†์Œ
      		</td>
      		<!-- <td></td>
      		<td></td>
      		<td></td>
      		<td></td> -->
      	</tr>
      	<tr><!-- 2ํ–‰ -->
      		<td class="centertext boldtext pinkcell">๋ณต๋ฌด๊ธฐ๊ฐ„</td>
      		<td colspan="4" class="centertext">
      			<input type="date"> ~ <input type="date">
      		</td>
      		<!-- <td></td>
      		<td></td>
      		<td></td> -->
      		<td class="centertext">
      			( <input type="number" class="width10"> ๋…„
      			 <input type="number" class="width10"> ๊ฐœ์›” )
      		</td>
      	</tr>
      	<tr><!-- 3ํ–‰ -->
      		<td class="centertext boldtext pinkcell">๊ตฐ๋ณ„</td>
      		<td class="centertext">
      			<input type="text" placeholder="๊ตฐํ•„" class="centertext">
      		</td>
      		<td class="centertext boldtext pinkcell">๊ณ„๊ธ‰</td>
      		<td class="centertext">
      			<input type="text" placeholder="๋ณ‘์žฅ" class="centertext">
      		</td>
      		<td class="centertext boldtext pinkcell">๋ณ‘์—ญ</td>
      		<td class="centertext">
      			<input type="text" placeholder="๋งŒ๊ธฐ์ œ๋Œ€" class="centertext">
      		</td>
      	</tr>
      </table>
      
      <table style="border: 0px solid #FFFFFF;">
      	<tr>
      		<td style="border: 0px solid #FFFFFF;">
      			<h2>&#9830; ์ž๊ฒฉ์ฆ ๋ฐ ๋ฉดํ—ˆ์‚ฌํ•ญ</h2>
      			<!-- ํ…Œ์ด๋ธ” 6 -->
      			<table>
      				<tr><!-- 1ํ–‰ -->
      					<td class="centertext boldtext pinkcell">์ž๊ฒฉ ๋ฐ ๋ฉดํ—ˆ๋ช…</td>
      					<td class="centertext boldtext pinkcell">์ทจ๋“์ผ</td>
      				</tr>
      				<tr><!-- 2ํ–‰ -->
      					<td class="centertext">
      						<input type="text" placeholder="์ž๋™์ฐจ ์šด์ „๋ฉดํ—ˆ์ฆ 2์ข…๋ณดํ†ต">
      					</td>
      					<td class="centertext">
      						<input type="date">
      					</td>
      				</tr>
      				<tr><!-- 3ํ–‰ -->
      					<td class="centertext">
      						<input type="text">
      					</td>
      					<td class="centertext">
      						<input type="date">
      					</td>
      				</tr>
      				<tr><!-- 4ํ–‰ -->
      					<td class="centertext">
      						<input type="text">
      					</td>
      					<td class="centertext">
      						<input type="date">
      					</td>
      				</tr>
      			</table>
      		</td>
      		<td style="border: 0px solid #FFFFFF;">
      			<h2>&#9830; ์™ธ๊ตญ์–ด ์‚ฌํ•ญ</h2>
      			<!-- ํ…Œ์ด๋ธ” 6 -->
      			<table>
      				<tr><!-- 1ํ–‰ -->
      					<td class="centertext boldtext pinkcell">์™ธ๊ตญ์–ด ๋ช…</td>
      					<td class="centertext boldtext pinkcell">ํšŒํ™” (์ƒ, ์ค‘, ํ•˜)</td>
      				</tr>
      				<tr><!-- 2ํ–‰ -->
      					<td class="centertext">
      						<input type="text">
      					</td>
      					<td class="centertext">
      						<input type="text">
      					</td>
      				</tr>
      				<tr><!-- 3ํ–‰ -->
      					<td class="centertext">
      						<input type="text">
      					</td>
      					<td class="centertext">
      						<input type="text">
      					</td>
      				</tr>
      				<tr><!-- 4ํ–‰ -->
      					<td class="centertext">
      						<input type="text">
      					</td>
      					<td class="centertext">
      						<input type="text">
      					</td>
      				</tr>
      			</table>
      		</td>
      	</tr>
      </table>
      <br>
      	<button type="submit">์ž…๋ ฅ</button>
	</form>
</body>
</html>

  • form action์— jsp ํŒŒ์ผ ์ง€์ • ๊ผญ ํ•ด์ฃผ๊ธฐ
    (method๋Š” ๋˜๋„๋ก ๊ฐ’์„ ์ˆจ๊ธธ ์ˆ˜ ์žˆ๋Š” post๋ฐฉ์‹ ์‚ฌ์šฉ)

  • ๋ถˆ๋Ÿฌ์˜ฌ ๊ฐ’์— ํ‚ค(name) ์ง€์ • ์žŠ์ง€ ๋ง๊ธฐ

<style>
   table, th, td {
      border: 1px solid #000000;
   }
   table {
      width: 100%;
      border-collapse: collapse;
   }
   .centertext {text-align: center;}
   .boldtext {font-weight: bold;}
   .pinkcell {background-color: #FFD9EC;}
   .width80 {width: 80%;}
   .width10 {width: 10%;}
   .border0 {border: 0px solid #FFFFFF;}
</style>
  • style ๋จผ์ € ์ ์šฉํ•ด๋†“๊ณ  class ๊ฐ€์ ธ๋‹ค ์“ฐ๊ธฐ (๊ตฌ๊ธ€๋ง ์ ๊ทน ํ™œ์šฉํ•˜๊ธฐ)
  • โญ ์ฃผ์„ ๋„ฃ๊ธฐ !! (ํ•œ๊ธ€๋กœ ์•Œ์•„๋ณด๊ธฐ ์‰ฝ๊ฒŒ ์ ๊ธฐ)
  • ์…€ ํ•ฉ์น ๋•Œ ์ง€์šฐ์ง€ ๋ง๊ณ  ์ฃผ์„ ์ฒ˜๋ฆฌ ํ•˜๊ธฐ (๊ฐ€๋…์„ฑ ๋†’ํžˆ๊ธฐ)
		<tr><!-- 1ํ–‰ -->
			<td rowspan="6"></td>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
		</tr>
		<tr><!-- 2ํ–‰ -->
			<!-- <td></td> -->
			<td>&nbsp;</td>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
		</tr>
  • ํ‘œ ํ…Œ์ŠคํŠธ ํ• ๋•Œ &nbsp; ๋„ฃ์–ด์„œ ํ…Œ์ŠคํŠธ ํ•˜๊ธฐ
  • text-align: center; ๋ฅผ td ์— ๋„ฃ๋Š” ๊ฒƒ์ด ๋” ๊น”๋”ํ•  ๊ฒƒ ๊ฐ™๋‹ค!! ๐Ÿง

๐Ÿ“๊ฒฐ๊ณผ

์™„์„ฑ๋œ html ํŽ˜์ด์ง€์— ์‚ฌ์šฉ์ž(ํด๋ผ์ด์–ธํŠธ)๊ฐ€ ์ •๋ณด๋ฅผ ์ž…๋ ฅํ•œ ๋’ค ์ž…๋ ฅ๋ฒ„ํŠผ์„ ๋ˆ„๋ฅด๋ฉด jsp๋กœ ์ •๋ณด(๊ฐ’)์„ ๋ถˆ๋Ÿฌ์˜ฌ ์ˆ˜ ์žˆ๋‹ค.

๐Ÿ“์ž‘์„ฑ (2) - resume.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>
</head>
<body>
<%
	// ์•ก์…˜JSP์—์„œ ํ•œ๊ธ€๋ฐ์ดํ„ฐ๋ฅผ ๋ฐ›๋Š” ๋ฐฉ๋ฒ•
	request.setCharacterEncoding("UTF-8");

	String pic = null;
	pic = request.getParameter("pic");
	System.out.println(pic);
	
	String name = null;
	name = request.getParameter("name");
	System.out.println(name);
	
	
%>
</body>
</html>
  • request.setCharacterEncoding("UTF-8");
    ์•ก์…˜ jsp์—์„œ ํ•œ๊ธ€ ๋ฐ์ดํ„ฐ๋ฅผ ๋ฐ›๋Š” ๋ฐฉ๋ฒ•
    (ํ•œ๊ธ€ ๋ฐ์ดํ„ฐ๋Š” ์ธ์ฝ”๋”ฉ์„ ์–ด๋–ป๊ฒŒ ํ•˜๋Š๋ƒ์— ๋”ฐ๋ผ ๊นจ์งˆ ์ˆ˜๋„ ์žˆ๊ธฐ ๋•Œ๋ฌธ์— request.getParameter ์ „์— ์ธ์ฝ”๋”ฉ์„ ์ง€์ • ํ•ด์•ผํ•œ๋‹ค)
    ํŠนํžˆ post ๋ฐฉ์‹์„ ์‚ฌ์šฉํ•œ๋‹ค๋ฉด ๊ผญ ์ธ์ฝ”๋”ฉ์„ ์ง€์ •ํ•ด์ฃผ๋Š” ๊ฒƒ์ด ์ข‹๋‹ค!

  • request.getParameter("ํ‚ค");
    ํ‚ค(name)์˜ ๊ฐ’์„ ๋ถˆ๋Ÿฌ์˜ค๋Š” ํ‘œํ˜„์‹, ํ•˜์ง€๋งŒ ๋ถˆ๋Ÿฌ์˜ค๊ธฐ๋งŒ ํ•˜๋ฉด ์•ˆ๋œ๋‹ค.
    โญ ๋ณ€์ˆ˜๋ฅผ ๋งŒ๋“ค์–ด์„œ ๋ณ€์ˆ˜๋ผ๋Š” ๊ณต๊ฐ„์— ๊ฐ’์„ ์ €์žฅํ•ด์•ผํ•จ!

  • String ๋ณ€์ˆ˜์ด๋ฆ„ = null;
    ๋ณ€์ˆ˜๋ฅผ ์„ ์–ธํ•˜๊ณ (๋งŒ๋“ค๊ณ ) null ๊ฐ’์„ ์ฃผ์–ด ๋ณ€์ˆ˜(๊ณต๊ฐ„)์„ ๋น„์šด๋‹ค.

  • ๋ณ€์ˆ˜์ด๋ฆ„ = request.getParameter("ํ‚ค");
    ํ‚ค ๊ฐ’์„ ๋ถˆ๋Ÿฌ์™€์„œ ๋ณ€์ˆ˜์— ์ €์žฅํ•œ๋‹ค.

  • System.out.println(๋ณ€์ˆ˜์ด๋ฆ„);
    ๋ณ€์ˆ˜์˜ ๊ฐ’์„ ์ฝ˜์†”์ฐฝ์— ์ถœ๋ ฅํ•œ๋‹ค.

  • <%out.print(๋ณ€์ˆ˜์ด๋ฆ„);%> ์™€ <%=๋ณ€์ˆ˜์ด๋ฆ„%>
    ๋ณ€์ˆ˜์˜ ๊ฐ’์„ ์›นํŽ˜์ด์ง€์— ์ถœ๋ ฅํ•œ๋‹ค.
    ๊ทธ๋Œ€๋กœ ๊ฐ’๋งŒ ์ถœ๋ ฅํ•  ์ˆ˜๋„ ์žˆ๊ณ , table์ด๋‚˜ input type์„ ์ด์šฉํ•˜์—ฌ ์ถœ๋ ฅํ•  ์ˆ˜๋„ ์žˆ๋‹ค.
    ๐Ÿ“ (์˜ˆ์‹œ)

	<table>
		<tr>
			<th>์•„์ด๋””</th>
			<td><%=id%></td>
		</tr>
		
		<tr>
			<th>๋น„๋ฐ€๋ฒˆํ˜ธ</th>
			<td><input type="password" value="<%=pw%>" readonly="readonly"></td>
		</tr>
		
		<tr>
			<th>์„ฑ๋ณ„</th>
			<td><%=gender%></td>
		</tr>
		
		<tr>
			<th>๊ตญ์ </th>
			<td><%=country%></td>
		</tr>
		
		<tr>
			<th>์ข‹์•„ํ•˜๋Š” ์ƒ‰์ƒ</th>
			<td>
				<input type="color" value="<%=likeColor%>" disabled="disabled">
				<!-- ์ƒ‰์ƒ์€ "์ฝ๋Š”๊ฒƒ"์ด ์•„๋‹ˆ๊ธฐ ๋•Œ๋ฌธ์— readonly๊ฐ€ ์•„๋‹ˆ๋ผ disabled๋ฅผ ์‚ฌ์šฉ -->
			</td>
		</tr>
	</table>
  • โญ ๋Œ€์ž…์—ฐ์‚ฐ์ž(=)
    ์™ผ์ชฝ ๋ณ€์ˆ˜์— ์˜ค๋ฅธ์ชฝ ๊ฐ’์„ ๋Œ€์ž…ํ•˜๋Š” ์—ฐ์‚ฐ์ž. ๊ฐ™๋‹ค๋Š” ๋œป์˜ =๊ฐ€ ์•„๋‹˜!
    (์˜ค๋ฅธ์ชฝ์— ํ‘œํ˜„์‹์ด ๋‚˜์˜ค๋ฉด ๊ฐ’์œผ๋กœ ๋ณ€ํ™˜ํ•œ ํ›„ ๋Œ€์ž…ํ•œ๋‹ค)
    ์ฆ‰, ์˜ค๋ฅธ์ชฝ์—” ๋ฌด์กฐ๊ฑด '๊ฐ’'์ด ์™€์•ผํ•˜๊ณ  (๋˜๋Š” ๊ฐ’์œผ๋กœ ๋ณ€ํ™˜ํ•  ์ˆ˜ ์žˆ๋Š” 'ํ‘œํ˜„์‹')
    ์™ผ์ชฝ์—๋Š” ๋ฌด์กฐ๊ฑด '๋ณ€์ˆ˜'๊ฐ€ ์™€์•ผํ•œ๋‹ค.

  • String pic = null;
    pic = request.getParameter("pic"); ๋Š” ๊ฐ„๋‹จํ•˜๊ฒŒ
    String pic = request.getParameter("pic"); ๋กœ ํ‘œํ˜„๊ฐ€๋Šฅ

๐Ÿ’ก์ž๋ฐ”์˜ ๊ธฐ๋ณธํƒ€์ž…๊ณผ String ํƒ€์ž…

  • ๊ธฐ๋ณธํƒ€์ž… (8๊ฐ€์ง€)

    • ์ •์ˆ˜
      • byte (1byte)
      • short (2byte)
      • int (4byte)
      • long (8byte)
    • ์‹ค์ˆ˜
      • float (4byte)
      • double (8byte)
    • ๋…ผ๋ฆฌ
      • boolean (์ฐธ, ๊ฑฐ์ง“)
    • ๋ฌธ์ž
      • char (2byte)
  • ์ฐธ์กฐํƒ€์ž…

    • ๋ฌธ์ž์—ด
      • String
        char ์„ ์—ฌ๋Ÿฌ๊ฐœ ์กฐํ•ฉํ•ด์„œ String ํƒ€์ž…์„ ๋งŒ๋“ฆ

์ •์ˆ˜๋Š” int ํƒ€์ž…,
์‹ค์ˆ˜๋Š” double ํƒ€์ž…์„ ๋งŽ์ด ์”€ (์˜ค์ฐจ๊ฐ€ ๊ทธ๋‚˜๋งˆ ์ ์Œ)

๐Ÿ’ก์—ฐ์‚ฐ์ž

  • ๋Œ€์ž…์—ฐ์‚ฐ์ž (=)
  • ๊ณฑํ•˜๊ธฐ (*)
  • ๋‚˜๋ˆ„๊ธฐ (/)
  • ๋‚˜๋จธ์ง€ ๊ตฌํ•˜๊ธฐ (%)

โœ๏ธ ๊ณ„์‚ฐ๊ฒฐ๊ณผ๊ฐ€ ์‹ค์ˆ˜์ด๋”๋ผ๋„ ์ •์ˆ˜์™€ ์ •์ˆ˜๋กœ ์—ฐ์‚ฐํ–ˆ๋‹ค๋ฉด ๊ฐ’์€ ๋ฌด์กฐ๊ฑด ์ •์ˆ˜๋กœ ์ถœ๋ ฅ๋œ๋‹ค. ์‹ค์ˆ˜๋กœ ๊ฐ’์ด ๋‚˜์˜ค๊ฒŒ ์—ฐ์‚ฐ์„ ํ•˜๊ณ  ์‹ถ๋‹ค๋ฉด ๋ณ€์ˆ˜ ํƒ€์ž…๊ณผ ๊ฐ’์„ ์‹ค์ˆ˜๋กœ ์ค˜์•ผํ•œ๋‹ค๋Š” ๊ฒƒ ๊ธฐ์–ตํ•˜๊ธฐ !


๐Ÿ“Œ ์˜ˆ์‹œ (1)

	y = y+1;
	y += 1;
	y++;

โœ๏ธ y์˜ ๊ฐ’์ด 1์”ฉ ์ฆ๊ฐ€! (์ฆ๊ฐ ์—ฐ์‚ฐ์ž)

๐Ÿ“Œ ์˜ˆ์‹œ (2)

  • ๋…ผ๋ฆฌ์—ฐ์‚ฐ์ž

    • and (&&)
    • or (||)
  • ๋น„๊ต์—ฐ์‚ฐ์ž

    • ๊ฐ™๋‹ค (==)
    • ๊ฐ™์ง€ ์•Š๋‹ค (!=)

โœ๏ธ ๋ฉ”์†Œ๋“œ ํ˜ธ์ถœ์ฝ”๋“œ(์‹)๋„ ํ‘œํ˜„์‹์ด๋‹ค.
โœ๏ธ ํ•˜๋‚˜๋ผ๋„ ๋ฌธ์ž์—ด์ด ์žˆ์œผ๋ฉด (+)๋Š” ์—ฐ๊ฒฐ์—ฐ์‚ฐ์ž๊ฐ€ ๋œ๋‹ค.

  • ๋ฌธ์ž์—ด+์ˆซ์ž์ด๋ฉด ์ˆซ์ž๊ฐ€ ์ž๋™์œผ๋กœ ๋ฌธ์ž์—ด๋กœ ๋ฐ”๋€๋‹ค.
    ex)
    out.print("2*"+1);
    out.print("2*"+"1");
    ๐Ÿ‘‰ 2*1์ด ์ถœ๋ ฅ๋จ

โœ๏ธ ๊ฐ ๋ฌธ์ž๋Š” ์ˆซ์ž ์ฝ”๋“œ๊ฐ€ ์ง€์ •๋˜์–ด ์žˆ๊ธฐ ๋•Œ๋ฌธ์— 'A'+'B'๋Š” AB๋กœ ์ถœ๋ ฅ๋˜๋Š” ๊ฒƒ์ด ์•„๋‹ˆ๋ผ 'A'์˜ ์ˆซ์ž ์ฝ”๋“œ์™€ 'B'์˜ ์ˆซ์ž ์ฝ”๋“œ์˜ ํ•ฉ์ธ 131 ์ด ์ถœ๋ ฅ๋œ๋‹ค.


profile
ํ•˜๋ฃจ ํ•œ๊ฑธ์Œ์”ฉ๐Ÿ’ช ์ดˆ๋ณด ๊ฐœ๋ฐœ์ž ๋„์ „๊ธฐ ๐ŸŒฑ๐Ÿ’ป

0๊ฐœ์˜ ๋Œ“๊ธ€