Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Eclipse 실행

준비한 Eclipse를 실행 합니다.

정보

Step 1: Create a New Dynamic Web Project in Eclipse

  1. Open Eclipse and go to File > New > Dynamic Web Project.
  2. Enter the Project Name: e.g., MyWebProject.
  3. Set the Target Runtime: Choose your server runtime (e.g., Apache Tomcat).
  4. Configure the Web Module:
    • Content Directory: Leave as WebContent.
    • Source Folder: Set it to src.
  5. Click Finish.

Step 2: Create the "libs" Folder for External Libraries

  1. Right-click on the Project in the Project Explorer.
  2. Choose New > Folder.
  3. Name the folder libs.
  4. Add External Libraries:
    • Download the necessary external libraries (e.g., Gson).
    • Copy the .jar files into the libs folder.

Step 3: Add the "libs" Folder to the Build Path

  1. Right-click on the Project and choose Build Path > Configure Build Path.
  2. Go to the Libraries tab.
  3. Click Add JARs....
  4. Navigate to the libs folder and select the .jar files.
  5. Click OK to add the libraries to the build path.

Step 4: Create a Simple Servlet

  1. Right-click on the src folder and choose New > Servlet.
  2. Name the servlet HelloServlet.
  3. Set the package name, e.g., com.example.
  4. Click Finish.

Step 5: Implement the Servlet

Edit the HelloServlet.java file:

Step 1) 프로젝트 생성

1. File > New > Dynamic Web Project.

...

3. 브라우저 창에서  http://localhost:8080/dynamic-web-example/HelloServlet 접속

4. JSON 회신 확인 

Project 구조

다음은 일반적인 dynamic 프로젝트의 폴더 구조를 나타낸다.

lua

MyWebProject/ ├── .classpath ├── .project ├── .settings/ ├── build/ ├── libs/ <-- External libraries │ └── gson-2.8.6.jar ├── src/ <-- Java source folder │ └── com/ │ └── example/ │ └── HelloServlet.java ├── WebContent/ │ ├── META-INF/ │ ├── WEB-INF/ │ │ ├── lib/ <-- Web app libraries (optional) │ │ ├── web.xml <-- Deployment descriptor (optional) │ └── index.jsp <-- Default JSP page └── build.xml

...