Servlet
- Servlet์ ์น ์๋ฒ์์ ๋์ํ๋ Java ํด๋์ค
- Which Version?
Simple Servlet
package com.okdevtv.crud;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import java.io.IOException;
import java.io.PrintWriter;
@WebServlet(name = "SimpleServlet", urlPatterns = {"/hello"})
public class SimpleServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");
String name = request.getParameter("name");
if (name == null) {
name = "";
}
PrintWriter out = response.getWriter();
out.println("<html><body>");
out.println("<h1>Hello, World!</h1>");
out.println("<p>์๋
ํ์ธ์! " + name + "</p>");
out.println("</body></html>");
}
}
ref
- Simple CRUD with JSP and Servlet example using Maven