A short presentation that explains the internals of the Spring Boot framework. Includes an example of a starter and an autoconfig artifac, and a github repo:
https://github.com/MichelSchudel/springbootunderdahood
Printing in Oracle Application Express (APEX) made easy. Make your template in Word, Excel or Powerpoint and print into Word, Excel, Powerpoint, PDF or HTML5. One APEX plugin, takes less than a minute to setup.
More info at https://www.apexofficeprint.com
A short presentation that explains the internals of the Spring Boot framework. Includes an example of a starter and an autoconfig artifac, and a github repo:
https://github.com/MichelSchudel/springbootunderdahood
Printing in Oracle Application Express (APEX) made easy. Make your template in Word, Excel or Powerpoint and print into Word, Excel, Powerpoint, PDF or HTML5. One APEX plugin, takes less than a minute to setup.
More info at https://www.apexofficeprint.com
JSP 프로그래밍 #02 서블릿과 JSP 시작하기
2.1 톰캣 애플리케이션 만들기 (온라인 강의: https://youtu.be/04LIGWKCFjY)
2.2 간단한 서블릿 만들기 (온라인 강의: https://youtu.be/4ajw5EsxYE8)
2.3 간단한 JSP 만들기 (온라인 강의: https://youtu.be/6h-qH8pGdT8)
2.4 간단한 자바빈즈 만들기 (온라인 강의: https://youtu.be/TlgXkAWi1sc)
This talk introduces Spring's REST stack - Spring MVC, Spring HATEOAS, Spring Data REST, Spring Security OAuth and Spring Social - while refining an API to move higher up the Richardson maturity model
JSONB in PostgreSQL is one of the main attractive feature for modern
application developers, no matter what some RDBMS purists are thinking.
People often use simple one-column-json schema for their projects and rely
on ability of database to store,index and query json. Postgres has long
history of supporting the non-structured data and has pioneered the
adoption of JSON by relational databases, so eventually JSON became and
official feature (SQL/JSON) of SQL standard.
Battle Of The Microservice Frameworks: Micronaut versus Quarkus edition! Michel Schudel
Micronaut and Quarkus are two cool emerging Java backend frameworks that aim to solve some problems that exist in current frameworks, like faster startup, low memory footprint, and support for ahead-of-time compilation using GraalVM. In this session, we'll square off both frameworks against each other.
How do they compare, what are the stronger and weaker points of both frameworks?
We'll compare the following features:
Initializing your project
Building your first restcontroller / programming model
Startup time
Database support
Integration test support
Building native images
Memory usage and JAR sizes
Ease of cloud deployment
In the end, we might have a clear winner! ... or will we?
This tutorial is about Spring Boot.
The tutorial includes an introduction to Spring Boot, key features of Spring Boot, prototyping using CLI, managing profiles aka environment in Grails, using GORM and using GSP. The tutorial begins with a section which is an introduction to Spring Boot. It includes an introduction to Spring Boot, the benefits of using Spring Boot.
Following is a features section which includes the key features of Spring Boot like embedded servers, security, metrics etc. Next is a section about prototyping. It includes prototyping using CLI, getting started, the things that happen during prototyping, starter POMs and a demo, building Gradle, using plugin and adding dependencies, and hot reloading.
Consecutively there is a section about managing profiles. It includes managing profiles aka managing environment in Grails like binding properties and its examples, using spring data to add dependency. Moreover, there's also a section which includes using GORM for next level persistence and also includes server side view template libraries like JSP, velocity, tiles, GSP etc.
The last section of this tutorial is about GSP. It includes using GSP with Spring Boot as it has limited tags, adds dependency and helps in packaging executable JAR and WAR files.
Parallel builds in Eclipse IDE workspace - EclispeCon Europe 2018Mickael Istria
https://www.eclipsecon.org/europe2018/sessions/parallel-builds-eclipse-ide-workspace-value-making-and-optimal-usages
Eclipse Platform 4.8 introduced support for parallel builds in the workspace. This feature is placed at the lowest level of the workspace so it can easily be profitable to any adopter without specific adoption effort, besides respecting usual good practices. This can in theory turn the Eclipse workspace into one of the fastest polyglot build engines in developer world.
In this presentation, we’ll explain what is the value to expect from this parallel builds (mostly performance gain and faster availability of project output).
Then we’ll also get into the details of how all that is implemented, reminding ourselves some basics of dependency resolution, graph processing and scheduling rules. We’ll remind the important best practices of builders and scheduling in the Eclipse resource model that are necessary to reach best results.
And we’ll go through a few case studies of project builders to highlight how those may be improved to take advantage of parallel builds, and get into deep details of how this can be enabled in JDT and other important Eclipse projects.
After this presentation, plugin developers will be empowered to make their project builders take advantage of parallel builds in Eclipse IDE, and may get ideas about really using this feature as an alternative build engine to speed up their headless builds as well.
Oracle Application Express (APEX) is shipped with several JavaScript libraries, jQuery being the best known one of them. And on top of these libraries the APEX Development Team created their own. You probably used a couple of these API's already, like $s, $v etc.
But there are way more and some of them are extremely useful. But first you have to be aware they exists. And secondly you have to know how to use the properly.
This session will cover the most valuable JavaScript API's with some real world examples.
Most developers stick to the standard $s and $v functions - even without knowing there is also a $v2 and $s can have more parameters.
The focus will be on the namespaced apex API's, like apex.server.process and apex.event.trigger.
In this talk, Jamie will demonstrate some core principles of a minimalist React framework called Next.js - We’ll also learn why SEO isn’t the only benefit of Server Side Rendering in React.
JSP 프로그래밍 #02 서블릿과 JSP 시작하기
2.1 톰캣 애플리케이션 만들기 (온라인 강의: https://youtu.be/04LIGWKCFjY)
2.2 간단한 서블릿 만들기 (온라인 강의: https://youtu.be/4ajw5EsxYE8)
2.3 간단한 JSP 만들기 (온라인 강의: https://youtu.be/6h-qH8pGdT8)
2.4 간단한 자바빈즈 만들기 (온라인 강의: https://youtu.be/TlgXkAWi1sc)
This talk introduces Spring's REST stack - Spring MVC, Spring HATEOAS, Spring Data REST, Spring Security OAuth and Spring Social - while refining an API to move higher up the Richardson maturity model
JSONB in PostgreSQL is one of the main attractive feature for modern
application developers, no matter what some RDBMS purists are thinking.
People often use simple one-column-json schema for their projects and rely
on ability of database to store,index and query json. Postgres has long
history of supporting the non-structured data and has pioneered the
adoption of JSON by relational databases, so eventually JSON became and
official feature (SQL/JSON) of SQL standard.
Battle Of The Microservice Frameworks: Micronaut versus Quarkus edition! Michel Schudel
Micronaut and Quarkus are two cool emerging Java backend frameworks that aim to solve some problems that exist in current frameworks, like faster startup, low memory footprint, and support for ahead-of-time compilation using GraalVM. In this session, we'll square off both frameworks against each other.
How do they compare, what are the stronger and weaker points of both frameworks?
We'll compare the following features:
Initializing your project
Building your first restcontroller / programming model
Startup time
Database support
Integration test support
Building native images
Memory usage and JAR sizes
Ease of cloud deployment
In the end, we might have a clear winner! ... or will we?
This tutorial is about Spring Boot.
The tutorial includes an introduction to Spring Boot, key features of Spring Boot, prototyping using CLI, managing profiles aka environment in Grails, using GORM and using GSP. The tutorial begins with a section which is an introduction to Spring Boot. It includes an introduction to Spring Boot, the benefits of using Spring Boot.
Following is a features section which includes the key features of Spring Boot like embedded servers, security, metrics etc. Next is a section about prototyping. It includes prototyping using CLI, getting started, the things that happen during prototyping, starter POMs and a demo, building Gradle, using plugin and adding dependencies, and hot reloading.
Consecutively there is a section about managing profiles. It includes managing profiles aka managing environment in Grails like binding properties and its examples, using spring data to add dependency. Moreover, there's also a section which includes using GORM for next level persistence and also includes server side view template libraries like JSP, velocity, tiles, GSP etc.
The last section of this tutorial is about GSP. It includes using GSP with Spring Boot as it has limited tags, adds dependency and helps in packaging executable JAR and WAR files.
Parallel builds in Eclipse IDE workspace - EclispeCon Europe 2018Mickael Istria
https://www.eclipsecon.org/europe2018/sessions/parallel-builds-eclipse-ide-workspace-value-making-and-optimal-usages
Eclipse Platform 4.8 introduced support for parallel builds in the workspace. This feature is placed at the lowest level of the workspace so it can easily be profitable to any adopter without specific adoption effort, besides respecting usual good practices. This can in theory turn the Eclipse workspace into one of the fastest polyglot build engines in developer world.
In this presentation, we’ll explain what is the value to expect from this parallel builds (mostly performance gain and faster availability of project output).
Then we’ll also get into the details of how all that is implemented, reminding ourselves some basics of dependency resolution, graph processing and scheduling rules. We’ll remind the important best practices of builders and scheduling in the Eclipse resource model that are necessary to reach best results.
And we’ll go through a few case studies of project builders to highlight how those may be improved to take advantage of parallel builds, and get into deep details of how this can be enabled in JDT and other important Eclipse projects.
After this presentation, plugin developers will be empowered to make their project builders take advantage of parallel builds in Eclipse IDE, and may get ideas about really using this feature as an alternative build engine to speed up their headless builds as well.
Oracle Application Express (APEX) is shipped with several JavaScript libraries, jQuery being the best known one of them. And on top of these libraries the APEX Development Team created their own. You probably used a couple of these API's already, like $s, $v etc.
But there are way more and some of them are extremely useful. But first you have to be aware they exists. And secondly you have to know how to use the properly.
This session will cover the most valuable JavaScript API's with some real world examples.
Most developers stick to the standard $s and $v functions - even without knowing there is also a $v2 and $s can have more parameters.
The focus will be on the namespaced apex API's, like apex.server.process and apex.event.trigger.
In this talk, Jamie will demonstrate some core principles of a minimalist React framework called Next.js - We’ll also learn why SEO isn’t the only benefit of Server Side Rendering in React.
node.js를 처음 접하는 개발자를 위한 스터디 자료입니다.
실습 위주로, 간단한 웹 페이지를 만들어 보는 것을 목표로 하며,
express를 활용하기에 앞서, node.js 기본 API만으로 GET/POST 처리 방식을 알아봅니다.
내용의 깊이가 있지는 않으며, 단지 node.js의 입문을 위한 가벼운 수준으로 내용이 구성되었습니다.
JSP 프로그래밍 #01 웹 프로그래밍
1.1 웹 (온라인 강의: https://youtu.be/qDZXXHhMr4A)
1.2 서블릿 (온라인 강의: https://youtu.be/a8hHeUhbz2k)
1.3 JSP(Java Server Page) (온라인 강의: https://youtu.be/Q4ezLP6KLwM)
1.4 프로그래밍을 위한 환경 설정 (온라인 강의: https://youtu.be/k2eR6gLULA8)
2018년 7월 5일에 있었던 한국인터넷거버넌스포럼(KrIGF)에서 발표한 "오픈 데이터와 인공지능" 발표자료입니다.
다음과 같은 내용을 담고 있습니다.
* 오픈데이터의 정의
* 오픈데이터의 중요성
* 인공지능
* 인공지능에서 데이터의 중요성
* 제한된 데이터 환경에서의 문제점
* 인공지능을 위한 오픈데이터의 중요성
* 더 나은 인공지능 시대를 위한 제언
2017년 4월에 진행된 도서관최신동향 과정에 있었던 발표자료입니다.
서지 분야에서의 Linked Data의 개념과 활용에 대한 내용을 담고 있습니다.
구체적으로는 아래와 같은 내용을 포함합니다.
- Linked Data란 무엇인가?
- 왜 도서관에서 Linked Data를 이야기하는가?
- Linked Data를 누가 쓰고 있나?
4. 3.1.1 웹 서버의 역할
▣ 일반적인 HTTP 요청 시
◈ 클라이언트의 요청이 전달되면 해당 HTML 문서가 웹 서버에 존재하는지
검사한 후 직접 서비스가 이루어진다.
▣ 서블릿 요청 시
◈ 웹 서버는 클라이언트로부터 전달된 요청 정보를 묶어서 서블릿 컨테이너
(Servlet Container)에게 전달
◈ 서블릿 컨테이너는 해당 서블릿을 검색한 후 서블릿이 존재하면 서블릿을
실행하여 클라이언트의 요청을 처리하고 응답해 준다.
Client
Web Server Servlet Container
Servlet
Servlet 클라이언트의 요청 종
류에 따라 웹 서버는
자신이 서비스를 해주
거나 서블릿 컨테이너
를 호출하여 서블릿을
실행한 후 응답한다.
HTML
HTML
5. 3.1.2 서블릿 컨테이너의 역할
▣ 요청 및 응답 객체 생성
◈ 웹 서버로부터 넘겨 받은 요청 정보를 이용해서 HttpServletRequest 객체와
HttpServletResponse 객체 생성
▣ 서블릿 객체 생성
◈ 서블릿 객체가 서블릿 컨테이너에 로딩되어 있다면, 바로 해당 서블릿 객체
생성
◈ 서블릿 객체가 서블릿 컨테이너에 로딩되어 있지 않다면, 해당 서블릿의 클
래스 파일(.class)을 로딩한 후 객체 생성
▣ 서블릿의 실행
◈ 사용자가 작성한 서블릿의 doGet() 메소드 호출
HttpServletRequest req = new HttpServletRequest();
HttpServletResponse res = new HttpServletRespone();
MyServlet m = new MyServlet();
m.doGet(req, res);
6. 3.1.3 프로그래머의 역할 (1)
▣ HttpServlet 클래스 상속
◈ 서블릿이 되기 위해서는 HttpServlet을 반드시 상속해야 한다.
◈ 서블릿 클래스는 반드시 public이어야 한다.
▣ doGet() 메소드 재정의
◈ doGet() 메소드의 매개변수 HttpServletRequest와 HttpServletResponse가 들
어 올 것이라는 가정하에 클라이언트로 서비스할 프로그램 작성
public class MyServlet extends HttpServlet {
...
}
public void doGet(HttpServletRequest req, HttpServletResponse res) {
…
}
서블릿 클래스는
누구나 호출해서
쓸 수 있는 public이
어야만 한다. 잊지
말자.
7. 3.1.4 프로그래머의 역할 (2)
▣ doGet() 메소드의 코드 작성
◈ HttpServletResponse 객체의 한글 처리 지정
◈ HttpServletResponse 객체로부터 클라이언트 스트림 얻기
◈ 클라이언트의 요청 정보인 HttpServletRequest의 정보 추출
res.setContentType("text/html;charset=euc-kr");
PrintWriter out = res.getWriter();
out.println(req.getProtocol() + "<br>");
out.println(req.getRemoteAddr() + "<br>");
out.println(req.getRemoteHost() + "<br>");
out.println(req.getScheme() + "<br>");
out.println(req.getServerName() + "<br>");
out.println(req.getServerPort() + "<br>");
8. 3.1.5 MyServlet 실행
Client
WebServer
서블릿 요청
서블릿 응답
http://localhost:8080/MySample/servlet/MyServlet
Servlet Container
MyServlet
doGet() 메소드 호출
invoke() 호출
MyServlet 객체가
로딩되어 있지 않
다면 MyServlet 객
체를 로딩한다.
MyServlet 검색
MyServlet 객체
생성 및 로딩
요청 정보를 이용해서
요청, 응답 객체 생성
invoker
없을 경우있을 경우
10. 3.2.1 서블릿의 상속 구조
ServletServletConfig Serializable
GenericServlet
HttpServlet
HTTP 프로토콜을 위한 HTTP 전용 서블릿
서블릿 환경을 위한 인터페이스 서블릿 기능 구현을 위한 인터페이스 서블릿 직렬화를 위한 인터페이스
interface interface interface
abstract
abstract
HttpServlet
구현
일반적인 네트워크 프로토콜을 위한 추상 서블릿
서블릿을 위해 필
요한 인터페이스들
을 구현해서 만든
추상 클래스
GenericServlet 추상 클
래스를 상속 받아
HTTP 프로토콜에 맞
게 만든 추상 클래스
가 바로 HttpServlet 클
래스이다.
11. Servlet Container
3.2.2 HttpServlet 클래스의 동작 과정
▣ HttpServlet 클래스는 GenericServlet 클래스를 상속받아 HTTP 프로토
콜에 맞게 작성한 클래스이다.
Web Server
Get Request
Post Request
Response
Response
extends HttpServlet
service()
doGet()
doPost()
HTTP 프로토콜을 통해 서
블릿 컨테이너에 요청이
들어오면 HttpServlet 클래
스의 service() 메소드가 가
장 먼저 호출된다.
service() 메소드에
서 HTTP의 요청
방식에 따라
doGet()이나
doPost() 메소드를
호출한다.
12. 3.2.3 GET 방식과 POST 방식
▣ GET 방식
◈ URL에 전달하고자 하는 정보를 포함해서 정보를 전달하는 방법
◈ 단점
– 정보가 노출되므로 보안 취약하다.
– 보내는 정보의 크기가 1024바이트로 제한된다
▣ POST 방식
◈ 전달하고자 하는 정보를 첨부파일 형태로 포함해서 전송하는 방법
◈ 장점
– URL의 주소 창에 보내는 정보에 대한 노출이 없기 때문에 보안성이 좋다.
– 보내는 정보의 크기에 제한이 없다.
요청_주소?파라미터이름=파라미터값&파라미터이름=파라미터값&...
GET 방식과 달리
파라미터 정보가
URL에 포함되지
않고 전달된다.
GET 방식은 URL 뒤
에 "?" 기호와 파라미
터 이름, "=" 기호, 그리
고 파라미터 값을 이용
해서 호출한다.
13. 3.2.4 GET 방식 처리를 위한 코드 작성하기
▣ doGet() 메소드 재정의
▣ doGet() 메소드의 코드 작성
◈ 파라미터 값 추출
public void doGet(HttpServletRequest req, HttpServletResponse res) {
…
}
String helloName = req.getParameter("name");
서블릿으로 전달된
HttpServletRequest 객체
의 getParameter() 메소
드를 이용해서 파라미
터의 값을 추출할 수 있
다.
14. 3.2.5 ExcuteGetServlet.html 작성하기 (1)
▣ <form> 태그
◈ 클라이언트에서 서버로 값을 전달하고자 할 때 사용하는 태그
▣ <form> 태그의 속성
◈ action 속성
– 사용자의 요청정보를 받아서 처리하는 CGI 프로그램의 위치를 지정
◈ method 속성
– 사용자의 요청정보를 어떤 방식으로 CGI 프로그램에 전달할 것인지를 지정
– GET과 POST 중 하나를 지정
<form action ="/MySample/servlet/HttpGetServlet" method="GET">
…
</form>
다음으로 실행될 서블릿의 위치를 지정 메시지 전달 방식
15. 3.2.6 ExcuteGetServlet.html 작성하기 (2)
▣ <input> 태그
◈ 텍스트 상자나 버튼을 만들기 위한 태그
◈ <input> 태그의 속성
– type 속성
• <input> 태그의 종류를 지정(text | submit)
– name 속성
• <input> 태그의 이름을 지정
• 파라미터 이름으로 사용된다.
– value 속성
• 버튼에 나타날 값을 지정
<input type="text" name="name" >
<input type="submit" value="Submit">
텍스트 박스 파라미터 이름
전송 버튼 버튼 이름
<input> 태그의 type 속
성을 submit으로 주면 버
튼이 만들어지며, 이 버
튼을 누르면 <form> 태
그의 action 속성에서 지
정된 서블릿이 실행된다.
16. 3.2.7 POST 방식 처리를 위한 코드 작성하기
▣ doPost() 메소드 재정의
▣ doPost() 메소드의 코드 작성
◈ 파라미터 값 추출
public void doPost(HttpServletRequest req, HttpServletResponse res) {
…
}
String helloName = req.getParameter("name");
서블릿으로 전달된
HttpServletRequest 객체
의 getParameter() 메소
드를 이용해서 파라미
터의 값을 추출할 수 있
다.
17. 3.2.8 ExcutePostServlet.html 작성하기
▣ <form> 태그
▣ <input> 태그
<form action ="/MySample/servlet/HttpPostServlet" method="POST">
…
</form>
다음으로 실행될 서블릿의 위치를 지정 메시지 전달 방식
<input type="text" name="name" >
<input type="submit" value="Submit">
텍스트 박스 파라미터 이름
전송 버튼 버튼 이름
<form> 태그의
method 속성 값이
POST이므로 POST
방식을 이용해서
파라미터가 전달된
다.
19. 3.3.1 서블릿 작업의 중심
▣ HttpServletRequest와 HttpServletResponse 객체
◈ doGet()과 doPost() 메소드의 매개변수로 넘어오는 인자 타입
◈ 클라이언트가 요청할 때 request와 response를 클래스의 형태로 맵핑
– 클라이언트의 요청 → HttpServletRequest request
– 클라이언트의 응답 → HttpServletResponse response
Client
Request
Response
Web Server
Servlet Container
extends HttpServlet
doGet(request, response)
doPost(request, response)
service(request, response)
HttpServletRequest
HttpServletResponse
클라이언트의 요
청 방식에 따라
doGet()과 doPost()
메소드가 알아서
호출된다.
20. 3.3.2 HttpServletRequest와 HttpServletResponse의 개요
▣ HttpServletRequest 객체
◈ 클라이언트의 모든 요청 정보를 포함
◈ 요청 HTTP 헤더 정보
◈ 서블릿으로 전달된 파라미터 정보
◈ InputStream 형태의 클라이언트로부터 전송된 데이터
◈ 세션(Session)과 쿠키(Cookie)와 같은 기타 정보
▣ HttpServletResponse 객체
◈ 클라이언트로 보내지는 응답 정보를 포함
◈ 응답 HTTP 헤더 정보
◈ OutputStream 형태의 클라이언트로 전송되는 데이터
◈ 세션과 쿠기 설정
21. 3.3.3 간단한 request와 response 예제
▣ HTML 작성
▣ 서블릿 작성
◈ Get 방식의 요청을 처리하기 위한 doGet() 메소드 재정의
◈ request 객체로부터 파라미터 값 얻기
◈ response 객체로부터 응답을 위한 스트림 객체 생성
public void doGet(HttpServletRequest request, HttpServletResponse response)
클라이언트의 요청 객체 클라이언트로의 응답 객체
String helloName = request.getParameter("name");
파라미터 이름
PrintWriter out = response.getWriter();
<form action ="/MySample/servlet/SimpleResponse" method="GET">
<input type="text" name="name" >
<input type="submit" value="submit">
</form>
23. 3.3.5 서블릿의 한글 문제
▣ response 객체의 한글 인코딩
◈ 응답으로 전송되는 response 객체의 한글 표현을 위해 한글 인코딩을 설정
해 주어야 한다.
▣ request 객체의 한글 인코딩
◈ 클라이언트로부터 POST 방식으로 전송된 요청 정보는 한글 인코딩을 설정
해 주어야 제대로 사용할 수 있다.
response.setContentType("text/html;charset=euc-kr");
request.setCharacterEncoding("euc-kr");
Client
Request
Response
Servlet Container
HttpServletRequest
HttpServletResponse
Servlet
response 객체 인코딩
request 객체 인코딩
25. 3.4.1 HTTP 요청 메시지의 구조
▣ HTTP 요청 메시지의 구성
◈ Request 요청 라인
◈ 헤더
◈ Entity Body
Request Line
Header Line
Entity Body
method URL version
Header_Field_Name : value
Header_Field_Name : value
…
Header_Field_Name : value
Request_Data
HTTP 프로토콜을
통해 전달되는 요
청 메시지는 아래
와 같은 구조를
갖는다.
26. 3.4.2 HTTP 요청 메시지의 헤더 출력
▣ request 객체로부터 헤더의 이름 집합(Enumeration) 얻기
▣ 헤더 이름 집합으로부터 헤더 얻기
Enumeration headerNames = request.getHeaderNames();
request 객체로부터 헤더의 이름 집합을 반환
while(headerNames.hasMoreElements()) {
String name = (String)headerNames.nextElement();
String value = request.getHeader(name);
}
Enumeration 객체로부터 다음 요소가 있는지 검사
Enumeration 객체로부터 다음 요소 반환
헤더 이름을 이용해서 해당 값 추출
28. 3.5.1 HTTP 응답 메시지의 구조
▣ HTTP 응답 메시지의 구성
◈ Response 상태 라인
◈ 헤더
◈ Data
Response Line
Header Line
Data
version Status
Header_Field_Name : value
Header_Field_Name : value
…
Header_Field_Name : value
Response_Data
200 OK
301 Moved Permanently
400 Bad Request
404 Not Found
505 HTTP Version Not Supported
Status Code
응답 메시지는
처리 결과에 따
라 상태 코드를
기술하여 전송한
다.
29. 3.5.2 response의 상태 코드
▣ 상태 코드(Status Code)
◈ HttpServletResponse 인터페이스에 상태 코드와 관련된 다양한 멤버 필드가
정의되어 있다.
▣ 상태 코드의 구분
◈ 200번대
– 클라이언트의 요청을 성공적으로 수행하였음을 의미
– HttpServletResponse.SC_OK : 정상적인 수행(200)
◈ 300번대
– 파일들이 이동되었을 때 사용되는 코드
– 파일의 이동 위치를 나타내는 Location 헤더가 포함된다.
◈ 400번대
– 클라이언트의 요청에 문제가 있을 경우 발생
– HttpServletResponse.SC_BAD_REQUEST : 잘못된 요청(400)
◈ 500번대
– 웹 서버가 클라이언트의 요청을 처리하는 도중 에러가 발생하였을 경우
– HttpServletResponse.SC_INTERNAL_SERVER_ERROR : HTTP 서버 에러(500)
30. 3.5.3 상태 코드 예제
▣ 파라미터 저장
▣ 파라미터 값에 따라 해당 에러 페이지 전송
int status = Integer.parseInt(request.getParameter("status"));
status 파라미터 값을 가져와서 int 형으로 변경
switch(status) {
case 400 :
response.sendError(HttpServletResponse.SC_BAD_REQUEST);
break;
case 404 :
response.sendError(HttpServletResponse.SC_NOT_FOUND);
break;
case 500 :
response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
break;
default :
response.sendError(HttpServletResponse.SC_OK);
}
파라미터 값에 따라 해당 에러 페이지 전송
31. 3.5.4 Refresh 헤더 항목 설정
▣ RefreshPage.java 작성
▣ RefreshPage.java 컴파일과 실행
response.setHeader("Refresh", "5;URL=http://www.jabook.co.kr");
Refresh 헤더 항목을 설정, 5초 후 다른 웹 사이트로 이동
C:...MySampleWEB-INFclasses> javac RefreshPage.java
http://localhost:8080/MySample/servlet/RefreshPage
HTTP
Response
Message