JSP
-
JSP 처리 과정JSP 2023. 3. 21. 10:32
톰캣 서버의 처리 과정 : 클라이언트로부터 WAS 에 요청이 들어오면 JSP와 관련된 서블릿 클래스가 있는 경우와 서블릿 클래스가 없는 경우. 두 가지의 처리 과정이 있다. 서블릿 클래스가 없는 경우 - JSP 페이지로부터 자바 코드를 생성한다. (변환) - 자바 코드를 컴파일해서 서블릿 클래스를 생성한다. (컴파일) - 서블릿에 클라이언트 요청을 전달한다. - 서블릿이 요청을 처리한 결과를 응답으로 생성한다. - 응답을 웹 브라우저에 전송한다. 서블릿 클래스가 있는 경우 - 서블릿에 클라이언트 요청을 전달한다. - 서블릿이 요청을 처리한 결과를 응답으로 생성한다. - 응답을 웹 브라우저에 전송한다. 출력 버퍼와 응답 : JSP 페이지는 응답 결과를 곧바로 웹 브라우저에 전송하지 않는다. 대신 출력버퍼에..
-
response 기본 객체JSP 2023. 3. 21. 09:48
response와 request response 기본 객체는 request 기본 객체와 반대의 기능을 수행한다. request는 웹 브라우저가 전송한 요청 정보를 담고있고 response는 웹 브라우저에 보내는 응답 정보를 담는다. response 기본 객체가 응답 정보와 관련해서 제공하는 기능들 중 2가지를 소개한다 - 헤더 정보 입력 - 리다이렉트 하기 ** response 기본 객체는 header 추가 메서드를 제공하는데 이 중 캐시를 제어하는 기능도 있다. 캐시를 이용하면 기존에 저장된 데이터를 화면에 띄워주기 때문에 응답시간이 줄어든다. 반면, DB에 새롭게 업데이트 된 내용이 출력되지 않기 때문에, DB 업데이트가 실시간으로 나타나야하는 게시판 같은 곳에는 사용하지 않도록 하자. 리다이렉트를 ..
-
Get 방식 전송과 Post 방식 전송JSP 2023. 3. 21. 09:18
웹 브라우저는 Get 방식과 post 방식이 있다. 아무런 설정을 하지 않으면 Get 방식이고, Get 방식이 Post보다 처리 속도가 빠르다. Get 방식 : URL의 경로 뒤에 물음표 ? 와 함께 파라미터를 붙여 전송하는데, 이를 뭐리 문자열 이라고 한다. 따라서 파라미터 전송 시, URI에 파라미터를 포함시켜 전송한다. -> a 태그가 기본적으로 get 방식이다. Post 방식 : 파라미터를 URL에 나타내지 않고 전송하기 때문에 보안이 강화된다. 따라서 파라미터 전송 시, 데이터 영역을 이용해서 파라미터를 전송한다. ( 전송할 수 있는 파라미티의 길이에 제한이 없다) 파라미터 값을 RFC 2396 규약에 정의된 규칙에 따라 인코딩해서 전송하기 때문에 한글로 인코딩 하는 과정에서 텍스트가 깨질 수 ..
-
Request 기본 객체JSP 2023. 3. 20. 15:10
1 _ 클라이언트 정보 및 서버 정보 읽기 주소를 분석해보면 localhost -> 서버이름 8090 -> 서버포트 Hojomu_JSP/requestInfo.jsp -> URI 2 _ HTML form과 요청 파라미터 : form 태그 내에서 submit 명령을 입력하면 input에 입력된 내용들을 action="URI"로 보낸다. - from 에서 보내진 데이터는 input의 name속성을 따라서 전해진다. - 파라메터의 값, 이름, Map 등 다양한 방법으로 파라메터를 받을 수 있다. Map - > 브라우저가 전송한 파라미터의 맵을 구한다 쌍으로 구성된다. ** 파라메터를 받는 메서드마다 리턴 타입이 다르다. getParameter : String getParameterVa..
-
JSP 의 구성요소JSP 2023. 3. 20. 10:51
1 _ JSP 구성요소 - JSP 파일은 1,2 번줄의 JSP 설정 문법과 그 외 나머지의 HTML코드 및 JSP 스크립트로 이루어진다. - JSP 페이지의 구성요소는 총 7가지가 있다. 1) 디렉티브 : JSP 페이지에 대한 설정 정보를 지정할 때 사용된다. 디렉티브 JSP가 제공하는 디렉티브 page : 페이지에 대한 정보 지정 ( 문서의 타입, 출력 버퍼의 크기, 에러 페이지등 ) taglib : 태그 라이브러리 지정 include : 특정 영역에 다른 문서를 포함시킴 디렉티브 주요 속성 - contentType : 문서의 MIME 타입과 캐릭터 인코딩 지정 - import : JSP페이지에서 사용할 자바 클래스 지정 - session : JSP 페이지가 세션을 사용할지의 여부를 지정 - buffe..
-
JSP 생성 프로젝트, 실행JSP 2023. 3. 20. 10:21
1 _ eclips에서 프로젝트 생성 : New project 생성 -> Dynamic Web Project 실행 - 좌측에 다음과 같이 JSP 프로젝트가 생성됬다. WebContent 폴더 내부에 .jsp 파일을 생성해서 사용한다. 해당 오류가 뜬다면, window -> show view -> servers 창을 열고 아래쪽에 뜬 servers 창에 나온 에러 코드를 더블클릭한 후, ports 칸에서 HTTP/1.1 의 Port Number를 변경한다. Tomcat admin port = 8005 HTTP/1.1 = 8090 으로 설정하고 다시 실행하자. 여러개의 포트를 사용하는 경우 중복되지 않도록 주의해야한다.