π»μ μ νμ΄μ§ μλ μ리
1. URL μ
λ ₯: μ¬μ©μκ° μΉ λΈλΌμ°μ μ μ£Όμμ°½μ μΉ νμ΄μ§μ URLμ μ
λ ₯νλ€.
2. μμ²: ν΄λΌμ΄μΈνΈμ λΈλΌμ°μ κ° μ
λ ₯ν URLμ κΈ°λ°μΌλ‘ ν΄λΉ μλ²λ‘ HTTP μμ²μ 보λΈλ€.
3. κ²μ: ν΄λΌμ΄μΈνΈκ° μμ²ν URLμ λλ©μΈ μ΄λ¦μ DNS(Domain Name System)μ μ¬μ©νμ¬ ν΄λΉ IP μ£Όμλ‘ λ³ννλ€. μ΄ν ν΄λΉ IP μ£Όμμ μλ²λ₯Ό μ°Ύμ μ°κ²°μ μλνλ€.
4. νμ₯μ νμ: μλ²λ ν΄λΌμ΄μΈνΈμ μμ²μ λ°κ³ , ν΄λΉ μμ²μ΄ μ μ νμ΄μ§μΈμ§ νμΈνκΈ° μν΄ νμ₯μλ₯Ό κ²μ¬νλ€. μλ₯Ό λ€μ΄, .html, .css, .js λ±μ νμ₯μλ μ μ νμ΄μ§λ₯Ό μλ―Ένλ€.
5. μμ€ μ½κΈ°: μμ²λ νμΌ(HTML, CSS, JavaScript λ±)μ΄ μλ²μ μ‘΄μ¬νλ©΄, μλ²λ ν΄λΉ νμΌμ λ΄μ©μ μ½μ΄λ€μΈλ€.
6. μλ΅: μλ²λ μ½μ΄λ€μΈ νμΌμ λ΄μ©μ ν΄λΌμ΄μΈνΈμκ² μλ΅μΌλ‘ μ μ‘ν©λλ€. μ΄ μλ΅μ HTTP μλ΅μΌλ‘, νμΌμ λ΄μ©κ³Ό ν¨κ» HTTP μν μ½λ λ±μ μ 보λ₯Ό ν¬ν¨νλ€.
μλ²λ μμ²μ λ°μΌλ©΄ μ μ₯λ νμΌμ κ·Έλλ‘ μ μ‘νλ―λ‘ μλ²μμ λ³λμ κ³μ°μ΄λ λ°μ΄ν°λ² μ΄μ€ μ°λμ΄ νμνμ§ μλ€.
7. μΊμ μ μ₯: ν΄λΌμ΄μΈνΈμ λΈλΌμ°μ λ λ°μ νμΌμ μΊμμ μ μ₯ν μ μλ€. λμΌν νμ΄μ§μ μ¬μ μν λ μΊμλ νμΌμ μ¬μ©νμ¬ λΉ λ₯΄κ² νμ΄μ§λ₯Ό λ λλ§ν μ μλ€.
8. μ€ν: ν΄λΌμ΄μΈνΈμ λΈλΌμ°μ λ λ°μ HTML, CSS, JavaScript λ±μ νμΌμ ν΄μνμ¬ νλ©΄μ νμνλ€. μ΄ λ¨κ³κ° μ¬μ©μκ° λ³Ό μ μλ μΉ νμ΄μ§μ΄λ€.
λ°νλ html νμ΄μ§μ μ€ννλ 주체λ λΈλΌμ°μ μ΄λ€. ν΄λΌμ΄μΈνΈλ λ°νλ νμΌμ κ·Έλλ‘ μ½μ§μκ³ μΊμμ μ μ₯νμ¬ μ μ₯ν 볡μ¬λ³Έμ μ½λλ€. μλ μλ νμ μ΄ λ§μ΄ λλ ΈκΈ°λλ¬Έμ νμ΄μ§ λ‘λνλλ° μκ°μ΄ μ€λκ±Έλ Έλ€.
첫방문 λ μΊμμ μ μ₯νκ³ λ³΅μ¬λ³Έμ μ½λλ€. λ€μ μ¬μ©μκ° κ°μ νμ΄μ§λ₯Ό μμ²ν λ, μΊμμ κ°μ νμΌμ΄ μλμ§ νμΈνκ³ κ°μ νμΌμ΄λ©΄ μλ²μ μμ²νμ§μκ³ μΊμμ μ μ₯λ 볡μ¬λ³Έμ λ€μ μ½λλ€. μ΄λ° λ°©μμΌλ‘ νμ λΉμ©μ μ€μΌ μ μλ€.
μμ¦μλ νμ μ΄ λΉ¨λΌμ‘μ§λ§, νμΌ μ©λλ€μ΄ 컀μ‘κΈ°λλ¬Έμ ν΄λΉ λ°©μμ μ¬μ©νλ€.
π»λμ νμ΄μ§ μλ μ리
1. URL μ
λ ₯: μ¬μ©μκ° μΉ λΈλΌμ°μ μ μ£Όμμ°½μ μΉ νμ΄μ§μ URLμ μ
λ ₯νλ€.
2. μμ²: ν΄λΌμ΄μΈνΈμ λΈλΌμ°μ κ° μ
λ ₯ν URLμ κΈ°λ°μΌλ‘ ν΄λΉ μλ²λ‘ HTTP μμ²μ 보λΈλ€.
3. web.xml νμΈ: μλΈλ¦Ώ 맀νκ³Ό κ°μ μ€μ μ 보λ₯Ό λ΄κ³ μλ web.xml μ€μ νμΌμ νμΈνλ€.
4. μλ° μμ€ νμΌ νμΈ: μμ²λ URLμ΄ μλΈλ¦Ώμ λν μμ²μΈ κ²½μ°, μΉ μλ²λ ν΄λΉ μλΈλ¦Ώμ Java μμ€ νμΌμ μ°Ύλλ€.
5. μ»΄νμΌ: μλΈλ¦Ώμ Java μμ€ νμΌμ μ»΄νμΌνμ¬ Java λ°μ΄νΈ μ½λλ‘ λ³ννλ€.
6. μ€ν: λ³νλ Java λ°μ΄νΈ μ½λλ₯Ό λ‘λ©νκ³ , μλΈλ¦Ώμ μ€ννλ€.
7. doGet() νΈμΆ: HTTP GET μμ²μ΄ λ€μ΄μμ κ²½μ°, μλΈλ¦Ώ 컨ν
μ΄λλ doGet() λ©μλλ₯Ό νΈμΆνλ€.
8. λμ νμ΄μ§ μμ±: doGet() λ©μλ μμμ νμν κ³μ°μ΄λ λ°μ΄ν°λ² μ΄μ€ μ°λ λ±μ μννμ¬ λμ μΌλ‘ νμ΄μ§μ μ½ν
μΈ λ₯Ό μμ±νλ€.
9. μΉμλ²μ λ°ν: μμ±λ λμ νμ΄μ§μ λ΄μ©μ HTTP μλ΅μ λ΄μ μΉ μλ²λ‘ λ°ννλ€.
10. μλ΅: μΉ μλ²λ λμ μΌλ‘ μμ±λ μ½ν
μΈ λ₯Ό ν¬ν¨ν HTTP μλ΅μ ν΄λΌμ΄μΈνΈμκ² μ μ‘νλ€.
11. μΊμ μ μ₯: ν΄λΌμ΄μΈνΈμ λΈλΌμ°μ λ λ°μ νμΌμ μΊμμ μ μ₯ν μ μλ€. λμΌν νμ΄μ§μ μ¬μ μν λ μΊμλ νμΌμ μ¬μ©νμ¬ λΉ λ₯΄κ² νμ΄μ§λ₯Ό λ λλ§ν μ μλ€.
12. μ€ν: ν΄λΌμ΄μΈνΈμ λΈλΌμ°μ λ λ°μ HTML, CSS, JavaScript λ±μ νμΌμ ν΄μνμ¬ νλ©΄μ νμνλ€. μ΄ λ¨κ³κ° μ¬μ©μκ° λ³Ό μ μλ μΉ νμ΄μ§μ΄λ€.
μνμΉμ ν°μΊ£μ λ€λ₯Έ νλ‘κ·Έλ¨μ΄λ€. μνμΉλ μΉμλ², ν°μΊ£μ μμ©νλ‘κ·Έλ¨ μλ²μ μν μ νλ€.
μΉ μλ²λ νμ΄μ§λ₯Ό μμ²λ°μΌλ©΄ μ°Ύμμ λ°νμ νλ€.
μμ©νλ‘κ·Έλ¨ μλ²λ μΉμλ²κ° κ°λΉν μ μλ μΌμ΄λΌκ³ μκ°νλ©΄, ν°μΊ£μ 맡νλ hi.do μ hi.javaλ₯Ό μκ³ μμ΄ hi.javaλ‘ μ°Ύμκ° μ μλ€. μ°Ύμ μλ° νμΌμ μ»΄νμΌνμ¬ ν΄λμ€ νμΌμ λ§λ λ€. ν΄λμ€ νμΌλ‘ java.exe λ₯Ό μ€ννλ€.
λ©λͺ¨λ¦¬μ μ€νν μλΈλ¦Ώ κ°μ²΄ μΈμ€ν΄μ€κ° μ¬λΌκ°λ€. μΈμ€ν΄μ€μ μλ doGet()λ₯Ό νΈμΆνλ€.κ²°κ³Όλ¬Όλ‘ html νμ΄μ§ ν μ₯μ΄ λμ¨λ€. μλ°μ½λκ° μλ doGet()μμ νΈμΆν HTML μ½λλ‘ κ²°κ³Όκ° λ§λ€μ΄μ§λ€. μλ²λ μλ°λ₯Ό ν΄μνμ¬ htmlλ₯Ό μμ±νκ³ κ·Έ κ²°κ³Όλ₯Ό ν΄λΌμ΄μΈνΈμ λ°ννλ€.
μλ° μμ κ³Ό κ΄λ ¨λ λͺ¨λ μΌμ ν°μΊ£μ΄ νλ€.
ν°μΊ£μ μλΈλ¦Ώμ μ€ννλ νκ²½μ μ 곡νλ€κ³ ν΄μ μλΈλ¦Ώ 컨ν μ΄λ, μμ©νλ‘κ·Έλ¨μλ²(Web Application Server) == WAS λΌκ³ λ λΆλ₯Έλ€.
π»μ½λ μ€ν λΉκ΅
μ μ νμ΄μ§
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<h1>Hello</h1>
<p>μλ
νμΈμ.</p>
<p id="time"></p>
<script>
document.getElementById('time').innerText = (new Date()).toLocaleTimeString();
</script>
</body>
</html>
λμ νμ΄μ§
package com.test.servlet;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class Hi extends HttpServlet{
public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException, ServletException {
resp.setCharacterEncoding("UTF-8");
PrintWriter writer = resp.getWriter();
writer.println("<!DOCTYPE html>"
+ "<html>"
+ "<head>"
+ "<meta charset=\"UTF-8\">"
+ "<title>Insert title here</title>"
+ "</head>"
+ "<body>"
+ " <h1>Hello</h1>"
+ " <p>μλ
νμΈμ</p>"
+ " <p id=\"time\"></p>"
+ " <script>"
+ " document.getElementByid('time').innerText = (new Data()).toLocalTimeString();"
+ " "
+ " </script>"
+ "</body>"
+ "</html>");
writer.close();
}
}
'SERVER(Servlet, JSP)' μΉ΄ν κ³ λ¦¬μ λ€λ₯Έ κΈ
[JSP] JSP νλ‘μ νΈ μμ± (0) | 2023.10.17 |
---|---|
[Servlet] λ°μ΄ν° μ μ‘ λ° μμ (0) | 2023.10.17 |
[servlet] servlet ν΄λμ€ μλ¬ λμ²λ² (0) | 2023.10.17 |
[Server] Servlet κΈ°μ΄ (0) | 2023.10.16 |
[Server]μ΄ν΄λ¦½μ€λ‘ μλ² νλ‘μ νΈ μμ±νκΈ° (0) | 2023.10.16 |