오늘의 노래 추천 👅
어떤남자가 불러줬으면 좋 겡 당 . . . 이하이는 더 잘돼야 합니다.
DAY 1
ㅡ Server & Client ㅡ
Asychronouse javascript and XM
request 와 response 를 주고받음
ㅡ> HTTP 라는 규칙을 사용해서 서버와 클라이언트 간에 데이터를 주고받음
서버는 response 로서 HTML, XML, 출력 결과 등을 전송
ㅡ 정적 웹서버 ㅡ
웹 서버에 미리 저장된 파일이 그대로 전달
저장파일이 변하지않는 이상 같은 출력
ㅡ 동적 웹서버 ㅡ
웹 서버의 데이터를 스크립에 의해 가공처리 후 생성되어 전달
* 사용자, 시간, 요청에 따라 상이한 출력
Server-side Programming
Client - Server 구조에서 Server에서 실행되는 소프트웨어
ㅡ Servlet ㅡ
Server + Java Applet
* Servlet 특징
1. 플랫폼 독립적 : Java 로 작성되어 어떤 플랫폼에서든 실행가능
2. 여러 Client 요청 동시처리 가능 : 웹 서버에 의해 인스턴스화 및 여러 스레드 생성
3. HttpServlet 클래스 상속받음**
ㅡ WAS ㅡ
Web Application Server
Servlet 은 HTML 을 뽑아내는 기계래요 ㅠㅠ
ㅡ> 서버 부하와 보안 등의 문제로 인해 정적 컨텐츠와 동적 컨텐츠를 분리
ㅡ CGIㅡ
Common Gateway Interface
Process ㅡ> 동적 상태 프로그램 / 운영체제가 메모리 등의 필요 자원을 할당 받은 상태
thread ㅡ> Process가 할당받은 자원을 이용하는 실행 단위
WAS 는 멀티 스레드를 사용하지만,
ㅡ> CGI 는 요청마다 Process 를 돌리기 때문에 요청이 많을 경우 메모리가 금방 부하됨
apache tomcat 과 eclipse 다운
https://tomcat.apache.org/download-90.cgi
ㅡ 문자 인코딩 (character encoding) ㅡ
ㅡ Servlet 생성 ㅡ
ㅡ Context Path ㅡ
* context path - 서버에 올릴 프로젝트의 고유한 식별자 name
ㅡ url mapping ㅡ
실제 Java Class 이름 대신 Servlet 을 요청하기 위한 문자열을 Servlet Class 와 Mapping 시키는 것
ㅡ> url 길이를 축소와 보안을 위해서
ㅡ Servlet 메서드 재정의 ㅡ
실제 Java Class 이름 대신 Servlet 을 요청하기 위한 문자열을 Servlet Class 와 Mapping 시키는 것
WAS 에서 Servlet 은 war 형태의 압축파일을 받아야함
이걸 Eclipse가 대신 해준 것 confiured 에 있는 war 파일
ㅡ url mapping 변경해보기 ㅡ
1. Annotation : url mapping 을 Ex01Servlet 에서 sohui 로 변경 ㅡ> WebServlet 괄호 안에서 변경
2. web.xml 이용하기
ㅡ context path 이름 변경해보기 ㅡ
서버 더블클릭 후 modules 선택
context path 이름을 Ex01Servlet 에서 ContextPah 로 변경
@WebServlet("/sohui")
public class Ex01Servlet extends HttpServlet {
private static final long serialVersionUID = 1L;
public Ex01Servlet() {
super();
// TODO Auto-generated constructor stub
}
public void init(ServletConfig config) throws ServletException {
System.out.println("초기화 시작");
}
public void destroy() {
System.out.println("destroy");
}
protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
System.out.println("서비스 시작");
}
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
System.out.println("doget 시작");
response.getWriter().append("Served at: ").append(request.getContextPath());
}
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
System.out.println("dopost 시작");
doGet(request, response);
}
ㅡ Servlet Life Cycle ㅡ
Servlet 객체 생성부터 소멸 과정
ㅡ HTTP 요청 테스트 해보기 ( postman 활용 ) ㅡ
postman api 다운로드
home 에서 new request 선택
postman 이 클라이언트로서 request 를 보낸것
* doget, dopost 메서드 실행을 위해서는 serive 메서드 주석처리
도메인 주소 : 네트워크 / url
BYE