package chap01.servlet;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@WebServlet("/hello")
public class HelloServlet extends HttpServlet {
@Override
protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
// JSP에서의 <% %> 부분
PrintWriter out = resp.getWriter();
out.print("<html><head><title>Hello Servlet</title></head><body>");
out.print("<h3>Hello!</h3>");
out.print("<p>Hello, Servlet</p>");
out.print("</body></html>");
}
}
📺 출력화면 >>