Publicité

Web Applications and Deployment

Manager, Technical Training à BG Java EE Course
17 Mar 2011
Publicité

Contenu connexe

Publicité

Web Applications and Deployment

  1. Java Web Applications and Deployment Svetlin Nakov Borislava Spasova
  2. Using Tomcat Web Application Server
  3. Java Web Applications Structure and Deployment
  4. Example – Login / Logout Web Application Structure The root directory of the Web application Classes of the application (including servlets) Libraries of the application (e.g. JDBC drivers) Deployment descriptor (configuration file) Public accessible files (HTML, JSP, CSS, ...) Special directory
  5. Sample web.xml File <?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?> <web-app version=&quot;2.4&quot; xmlns=&quot;http://java.sun.com/xml/ns/j2ee&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xsi:schemaLocation=&quot;http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd&quot;> <servlet> <servlet-name>TimeServlet</servlet-name> <servlet-class>TimeServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>TimeServlet</servlet-name> <url-pattern>/TimeServlet</url-pattern> </servlet-mapping> <session-config> <session-timeout>30</session-timeout> </session-config> <welcome-file-list> <welcome-file>index.jsp</welcome-file> </welcome-file-list> </web-app>
  6. Creating Web Application and Deploying on Tomcat (2) <?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?> <web-app version=&quot;2.4&quot; xmlns= &quot;http://java.sun.com/xml/ns/j2ee&quot; xmlns:xsi= &quot;http://www.w3.org/2001/XMLSchema-instance&quot; xsi:schemaLocation=&quot;http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd&quot;> <servlet> <servlet-name> Hello Servlet</servlet-name> <servlet-class> Hello Servlet</servlet-class> </servlet> <servlet-mapping> <servlet-name> Hello Servlet</servlet-name> <url-pattern>/ Hello Servlet</url-pattern> </servlet-mapping> </web-app> web.xml

Notes de l'éditeur

  1. webapp directory is considered the Web application root directory. All JSP, HTML, JavaScript files, and other resources are under this directory. The WEB-INF directory contains resources used by the application, WEB-INF is not in the public document root—no files contained in this directory structure are accessible by a client. The classes directory (under WEB-INF) contains servlets, beans, and utility classes needed for webapp&apos;s operation. lib directory (under WEB-INF) contains Java archive files (JARs), such as the JDBC driver or tag library, on which webapp depends. If a class is present in a JAR file and in the classes directory, the class loader loads the one in the classes directory.
  2. Notes Order matters: servlet before servlet-mapping JSP: Use jsp-file instead of servlet-class
Publicité