1 / 10

SERVLET

SERVLET. 동국대학교 과학기술대학 컴퓨터멀티미디어학부 DB&WE Lab. 변정용. Tomcat installation. Download http://jakarta.apache.org On /usr/local/tomcat Tomcat-5.0.9 Java Development Kit /usr/j2se J2SE or jdk1.5. Servlet: Setting and revising 1. JAVA_HOME=/usr/j2se setenv JAVA_HOME=/usr/j2se on UNIX root

murray
Télécharger la présentation

SERVLET

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. SERVLET 동국대학교 과학기술대학 컴퓨터멀티미디어학부 DB&WE Lab. 변정용 동국대-변정용

  2. Tomcat installation • Download • http://jakarta.apache.org • On /usr/local/tomcat • Tomcat-5.0.9 • Java Development Kit • /usr/j2se • J2SE or jdk1.5 동국대-변정용

  3. Servlet: Setting and revising 1 • JAVA_HOME=/usr/j2se • setenv JAVA_HOME=/usr/j2se on UNIX root • jre/ext에 tomcat/lib/servlet-api.jar 복사 • /alpit/conf/server.xml • Context path=/alpit docBase=/usr/home/byunjy/www/alpit 동국대-변정용

  4. Servlet: Setting and revising 2 • Make directory • Login: honggd passwd: honggd • Cd www • Mkdir alpit • Make sub-directory • Mkdir WEB-INF • Cd WEB-INF • Copying web.xml to here • Mkdir classes • Mkdir lib 동국대-변정용

  5. Servlet: Setting and revising 3 • /alpit/conf/web.xml <servlet> <servlet-name>invoker</servlet-name> <servlet-class> org.apache.catalina.servlets.InvokerServlet </servlet-class> </servlet> <servlet-mapping> <servlet-name>invoker</servlet-name> <url-pattern>/servlet/*</url-pattern> </servlet-mapping> 동국대-변정용

  6. Tomcat startup & shutdown • Cd bin • Conf 수정 후 반드시 tomcat stop and startup • For Unix • Startup.sh • Shutdown.sh • For window • Startup.bat • Shutdown.bat • For both, click bootstrap 동국대-변정용

  7. Servlet: placing, compile, and run • /alpit/WEB-INF/classes • Copy HelloServlet.java • Javac HelloServlet.java • HelloServlet.class 생성 • Web browser • http://solgeo.dongguk.ac.kr:8080/alpit/servlet/HelloServlet • 답: Hello Servlet!!! by Prof. Byun 동국대-변정용

  8. HelloServlet.java import java.io.*; import javax.servlet.*; import javax.servlet.http.*; public class HelloServlet extends HttpServlet { public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { res.setContentType("text/html;charset=KSC5601"); PrintWriter out = res.getWriter(); out.println("<html>"); out.println("<head><title>Hello World</title>"); out.println("<body>"); out.println("<h1>Hello Servlet!!!</h1>"); out.println("<br><font color=blue> by prof. Byun</font>"); out.println("</body>"); out.println("</html>"); } } 동국대-변정용

  9. iframe.html <html> <head><title>IFRAME TAG</title></head> <body> <h1>Calling Hello Servlet</h1> <p> <iframe src=servlet/HelloServlet width=500 height=500 scrolling=auto> </iframe> </body> </html> 동국대-변정용

  10. Calling servlet through html • Setting • Placing iframe.html to alpit • Result • Calling Hello Servlet • Hello Servlet!! • By Prof. Byunjy 동국대-변정용

More Related