Servlet의 특징
슈퍼클래스 부모클래스 를 HttpServlet 클래스를 상속받아야 서블릿 클래스가 됨
닉네임을 정해줘야함, /Ex로 mappings
이게 default
서블릿 생성!
package com.javalec.ex;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
* Servlet implementation class HelloWorld
*/
public class HelloWorld extends HttpServlet {
private static final long serialVersionUID = 1L;
/**
* @see HttpServlet#HttpServlet()
*/
public HelloWorld() {
super();
// TODO Auto-generated constructor stub
}
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
System.out.println("HelloWorld");
}
/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
doGet(request, response);
}
}
브라우저에는 아무것도 안뜨지만 콘솔창에는 sysout 사용한게 뜸!
너무 길고, 보안에 노출되어있는 경로를 간단하게 맵핑하는 것