상위 질문
타임라인
채팅
관점
자바 서블릿
위키백과, 무료 백과사전
Remove ads

자바 서블릿(Java Servlet)은 자바를 사용하여 웹페이지를 동적으로 생성하는 서버측 프로그램 혹은 그 사양을 말하며, 흔히 "서블릿"이라 불린다. 자바 서블릿은 웹 서버의 성능을 향상하기 위해 사용되는 '자바 클래스'의 일종이다. 서블릿은 JSP와 비슷한 점이 있지만, JSP가 HTML 문서 안에 자바 코드를 포함하고 있는 반면, 서블릿은 자바 코드 안에 HTML을 포함하고 있다는 차이점이 있다.

자바 서블릿은 자바 EE 사양의 일부분으로, 주로 이 기능을 이용하여 쇼핑몰이나 온라인 뱅킹 등의 다양한 웹 시스템이 구현되고 있다.
비슷한 기술로는 펄 등을 이용한 CGI, PHP를 아파치 웹 서버 프로세스에서 동작하게 하는 mod_php, 마이크로소프트사의 IIS에서 동작하는 ASP 등이 있다. CGI는 요청이 있을 때마다 새로운 프로세스가 생성되어 응답하는 데 비해, 자바 서블릿은 외부 요청마다 프로세스보다 가벼운 스레드로써 응답하므로 보다 가볍다. 또한, 자바 서블릿은 자바로 구현되므로 다양한 플랫폼에서 동작한다.
Remove ads
버전의 역사
자바 서블릿 API는 1996년 5월 자바원 콘퍼런스에서 처음 공식 발표되었다.[1][2] 콘퍼런스 발표 이후 약 2개월 째 되던 날, 자바소프트 웹사이트에 최초 공개 구현체가 만들어졌다. 이것은 최초 알파 버전의 자바 웹 서버(Java Web Server, JWS. 코드명 Jeeves)[3]였으며 1997년 6월 5일 최종 제품화되었다.[4]
서블릿1 사양은 Pavni Diwanji가[5] 썬 마이크로시스템즈에서 일하는 동안 개발한 것으로, 버전 1.0은 1997년 6월 완성되었다. 버전 2.2를 기점으로 이 사양은 자바 커뮤니티 프로세스를 통해 개발되었다.
Remove ads
아파치 톰캣 호환정보
- (영어) Apache Tomcat
- (영어) Tomcat is a free, open-source implementation of Java Servlet and JavaServer Pages technologies developed under the Jakarta project at the Apache Software Foundation. Sun adapts and integrates the Tomcat code base into the J2EE Reference Implementation. Tomcat is available for commercial use under the ASF license from the Apache web site in both binary and source versions.
- 4.X Release Build : Tomcat 4 is an implementation of the Java Servlet 2.3 specification.
- 3.3 Release Build : Tomcat 3.3 is an implementation of the Java Servlet 2.2 specification.
- (영어) Tomcat is available at the Jakarta binary downloads page.
- Tomcat 3 supports the Servlet 2.2 and JSP 1.1 specifications with minimum Java Version 1.1.
- Tomcat 4 supports the Servlet 2.3 and JSP 1.2 specifications with minimum Java Version 1.3.
- Tomcat 5 supports the Servlet 2.4 and JSP 2.0 specifications with minimum Java Version 1.4.
- Tomcat 6 supports the Servlet 2.5 and JSP 2.1 specifications with minimum Java Version 1.5.
- Tomcat 7 supports the Servlet 3.0 and JSP 2.2 specifications with minimum Java Version 1.6.
Remove ads
예제
import java.io.IOException;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class ServletLifeCycleExample extends HttpServlet {
private int count;
@Override
public void init(ServletConfig config) throws ServletException {
super.init(config);
getServletContext().log("init() called");
count = 0;
}
@Override
protected void service(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
getServletContext().log("service() called");
count++;
response.getWriter().write("Incrementing the count: count = " + count);
}
@Override
public void destroy() {
getServletContext().log("destroy() called");
}
}
각주
외부 링크
Wikiwand - on
Seamless Wikipedia browsing. On steroids.
Remove ads