달력

4

« 2024/4 »

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
2007. 10. 23. 10:24

JSP & Servlet 교육 Day 2nd. 그거/Seminar2007. 10. 23. 10:24


장소 : 썬 교육센터
날짜 : 10.22 ~ 10.26
시간 : 09:30 ~ 17:30
내용 : Web Component Developement with Servlet and JSP Technologies

# Day 2

Developing View Component

## Use Case
         Actor                           Use Case
   ---------------------------------------------------------
   Player                         List all avaliable leagues
                                  Register for a league

   League Administrator           Add a new league
     

## View 설계 및 구현 (List all avaliable leagues : Player)
   index.html
   list_league.view

   * html 파일은 더 이상 수정하지 않을 페이지
   * view 파일은 개발자가 계속 수정하면서 사용할 페이지

   League Bean 생성
   ListLeagueServlet 생성

   * eclipse에 tomcat을 연동한 후에
     Dynamic Web Project를 생성하여 위 작업을 할 경우
     eclipse에서 src, build. webContent 디렉토리가 생성된다.
     src 에서 생성된 java 파일의 class 파일들이 build/classes 에 생성이 되는데
     흔히 알고 있는 WEB-INF\classes 밑에 servlet의 class 파일들이 없어도 servlet이 잘된다.
   * tomcat에서 web.xml에 있는 invoker servlet에 대해서 주석을 해제시키지 않아도
     servlet이 잘 된다.(이건 왜 그런지 참 신기허다. 알고 있기로는 주석을 빼줘야 하는데..)
   * tomcat에 context를 추가할 때 $TOMCAT_HOME/conf/Catalina/localhostxml 파일을 추가해줘야
     context가 추가되는 걸로 알고 있었는데, $TOMCAT_HOME/webapps/ 밑에는 그냥 디렉토리 만들고
     WEB-INF, WEB-INF/classes, WEB-INF/web.xml 들만 추가해주면 context가 추가된다.


## 웹로직 설치 & 환경 설정

웹로직 설치
  server812_win32.exe

WebLogic 설정
  시작->프로그램->Bea weblogic platform 8.1 ->
Configuration Wizard
  작업 도메인을 mydomain 으로 한다.

환경설정
  user_projects\mydomain\startWebLogic.cmd 수정
    set CLASSPATH=.;%WEBLOGIC_CLASSPATH%.....

  user_project\mydomain\setEnv.cmd 수정
    set CLASSPATH=.;%WEBLOGIC_CLASSPATH......

  path에 수정
    C:\bea\user_projects\domains\mydomain
추가


## 서블릿과 JSP 운용

  디렉토리 구조
    webtest -+--- WEB-INF ------------- classes  (java class file : 서블릿, DTO)
             |         |
             |         +--------------- lib      (class library   : .jar 파일)
             |         |
             |         +--------------- src      (java sourc file : .java 파일)
             |         |
             |         +--------------- web.xml, weblogic.xml
             |
             +---- html 파일, jsp 파일
    required -> WEB-INF, web.xml, weblogic.xml


## Packaging Applications

  File Contents                                   Type of File
  --------------------                            -------------------
  EJB Component JAR                              
  Helper Classes JAR File          ----->         EAR file ( .ear )
  WAR File
  RAR File

  Bean Implementation Class
  Helper Classes                   ----->         EJB Component JAR file ( .jar )
  Interfaces
  Deployment Descriptor

  HTML
  JSP
  Servlets                         ----->         Web Component or Web Archive ( .war )
  Helper Classes
  Deployment Descriptor


## 웹로직에 Web Application 배포

  C:\bea\user_projects\domains\mydomain\applications

  폴더 밑에 작업한 디렉토리(webtest)를 복사하거나 위 경로에 webtest 디렉토리를 만들고 작업을 한다.

  WebLogic Server Console에서 확인한다.

  mydomain -> Deployments -> Web Application Modules

  위 메뉴를 따라가서 보면 _appsdir_webtest_dir 라는 이름으로 webtest가 Web Application이 Deploy 됐음을 확인할 수 있다.

  http://localhost:7001/webtest/index.html 을 브라우저에서 실행해서 제대로 보이는지 확인한다.

  C:\bea\user_projects\domains\mydomain\config.xml 파일에 아래 내용이 추가됐음을 확인할 수 있다.
      <Application Name="_appsdir_webtest_dir"
        Path="C:\bea\user_projects\domains\mydomain\applications"
        StagingMode="nostage" TwoPhase="true">
        <WebAppComponent Name="webtest" Targets="myserver" URI="webtest"/>
      </Application>


weblogic.xml 를 아래처럼 수정
<weblogic-web-app>
 <context-root>/</context-root>
</weblogic-web-app>


위와 같이 하면 http://localhost:7001/webtest/index.html 이렇게 하지 않고
http://localhost:7001/index.html 이렇게 호출하여 사용할 수 있다.

HelloWorldServlet.java, CounterServlet.java 파일을 생성하고
WEB-INF\classes 에 위 java 파일들을 컴파일 하여 class 파일을 위치시킨 후에
web.xml 파일에 아래 내용을 추가한다.

 <servlet>
  <servlet-name>HelloWorld</servlet-name>
  <servlet-class>examples.HelloWorldServlet</servlet-class>
 </servlet>

 <servlet>
  <servlet-name>Counter</servlet-name>
  <servlet-class>examples.CounterServlet</servlet-class>
 </servlet>

 <servlet-mapping>
  <servlet-name>HelloWorld</servlet-name>
  <url-pattern>/hello</url-pattern>
 </servlet-mapping>

 <servlet-mapping>
  <servlet-name>Counter</servlet-name>
  <url-pattern>/counter</url-pattern>
 </servlet-mapping>



  * java 파일을 컴파일 할 경우 컴파일을 실행할 도스창(cmd)에서
   C:\bea\user_projects\domains\mydomain
밑에 있는 setEnv.cmd 파일을 실행하여
    컴파일에 필요한 classpath 등에 대해서 자동으로 설정하도록 한다.

추가한 후에 webtest application을 재배포한 후에 브라우저에서
http://localhost:7001/hello, http://localhost:7001/counter 를 호출하여 페이지를 확인한다.

:
Posted by 뽀기