개요
 일반적인 웹서버에 JSP나 Servlet을 실행시키기 위해선 Servlet Container가 필요하다.
대략적인 절차는 아래와 같다.

[클라이언트는 서버에 Request 전송] -> [웹서버가 받는 Request를 객체화]  -> [Servlet Container에 전달하여 Response 객체생성] -> [Response 객체를 웹서버에 전달] -> [웹서버는 Response를 HTTP로 변환, Client에 전송]  

필요한 절차
1. J2SE 설치
2. J2EE 설치
3. Eclipse(이클립스) 설치 : WTP-all-in-one 버전
4. Web Server 설치 : Tomcat
5. Eclipse Runtime 환경 구축
6. Hello World 작성하기

구체적인 절차
1. J2SE 설치
   (생략)

2. J2EE 설치
   (생략)

3. Eclipse 설치 : WTP-all-in-one 버전
 - WTP(Web Tool Platform)는 이클립스상에서 웹개발을 지원하기 위한 프로젝트다.
  해당 홈페이지 : http://www.eclipse.org/webtools/
 - 이클립스에서 원활히 동작하게 하기위해서는 다수의 plugin 설치가 필요하나, 절차가 복작하여 필요한 플러그인을 하나로 모은 WTP-all-in-one 버전이 존재함
  다운로드 http://download.eclipse.org/webtools/downloads/drops/R2.0/R-2.0.1-20070926042742/

사용자 삽입 이미지

 운영체제별 버전이 따로 존재하니 알아서 받자.
 07.11.21 기준 2.x 버전이 최신 버전, 3.x 버전은 존재하나 All-in-one Version은 미출시 상태

4. Web Server 설치 : Tomcat
 가장 보편적으로 사용되는 Tomcat을 설치하자
 해당사이트 : http://tomcat.apache.org/
 6.x 버전 다운로드 : http://mirror.apache-kr.org/tomcat/tomcat-6/v6.0.14/bin/apache-tomcat-6.0.14.zip

5. Eclipse Runtime 환경 구축
  (will be updated..)

6. Hello World 작성하기
 그림 넣고 글몇자 적는거 보다 동영상이 최고의 효과인듯, 보고 따라해보자.
 관련 동영상 http://download.eclipse.org/technology/phoenix/demos/install-wtp/install-wtp.html

소스코드(Source Code)
------------------------------------------------------------------------------------------
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.awt.image.*;
import java.io.*;
import com.sun.image.codec.jpeg.*;

public class Main extends JPanel implements Runnable, ActionListener{
 
 JButton btn_capture;
 Image img = null;
 
 public Main()
 {
  this.btn_capture = new JButton("영상캡쳐");
  this.btn_capture.addActionListener(this);
  this.setLayout(new BorderLayout());
  this.add(this.btn_capture, BorderLayout.SOUTH);
 }
 
 public void actionPerformed(ActionEvent e)
 {
  String cmd = e.getActionCommand();
  if(cmd.equals("영상캡쳐"))
  {
   System.out.println("영상을 캡쳐합니다..");
   this.capture();
  }
 }
 
 private void drawImage(Image img, int x, int y)
 {
  Graphics g = this.getGraphics();
  g.drawImage(img,0,0,x,y,this);
  this.paint(g);
  this.repaint();
 }
 
 public void paint(Graphics g)
 {
  if(this.img != null)
   g.drawImage(this.img, 0, 0, this.img.getWidth(this), this.img.getHeight(this), this);
 }
 
 public void capture()
 {
  Robot robot;
  BufferedImage bufImage = null;
  try
  {
   robot = new Robot();
   Rectangle area = new Rectangle(Toolkit.getDefaultToolkit().getScreenSize());
   
   bufImage = robot.createScreenCapture(area);
   
   //Graphics2D g2d = bufImage.createGraphics();
   int w = this.getWidth();
   int h = this.getHeight();
   
   this.img = bufImage.getScaledInstance(w, h-20, Image.SCALE_DEFAULT);
   //this.repaint();
   this.drawImage(img, w, h);
   //saveJPEGfile("c:\\cap.jpg", bufImage);
  }
  catch(Exception e)
  {
   e.printStackTrace();
  }
 }
 
 public static boolean saveJPEGfile(String filename, BufferedImage bi)
 {
  FileOutputStream out = null;
  try
    {
     out = new FileOutputStream ( filename );
     JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder ( out );
     JPEGEncodeParam param = encoder.getDefaultJPEGEncodeParam ( bi );
     param.setQuality ( 1.0f, false );
     encoder.setJPEGEncodeParam ( param );
 
     encoder.encode ( bi );
     out.close();
    }
    catch ( Exception ex )
    {
     System.out.println ("Error saving JPEG : " + ex.getMessage() );
     return false;
    }
  return true;
 }
 
 
 public void run()
 {
  while(true)
  {
   this.setBackground(Color.RED);
   try
   {
    Thread.sleep(1000);
   }catch(Exception e){}
   this.setBackground(Color.GREEN);
   
   try
   {
    Thread.sleep(1000);
   }catch(Exception e){}
  }
 
 }
 
 public static void createFrame()
 {
  JFrame frame = new JFrame("Jv");
  JFrame.setDefaultLookAndFeelDecorated(true);
  Container cont = frame.getContentPane();
  cont.setLayout(new BorderLayout());
  Main mm = new Main();
  //new Thread(mm).start();
  cont.add(mm, BorderLayout.CENTER);
 
  frame.setSize(400, 400);
  frame.setVisible(true);
 }
 
 public static void main(String...v)
 {
  //new Main();
  JFrame.setDefaultLookAndFeelDecorated(true);
  createFrame();
 }
}
------------------------------------------------------------------------------------------------

+ Recent posts