|
While more and more server based frameworks, libraries, standards, and architectures for Java are invented to make the programmer's life easier, software deployment seems to get harder and harder. For example, Java Enterprise Beans tried to make the creation of persistent and networked objects easy and somewhat automatic, but the number of deployment descriptions got enormous. As Vaadin lives in a Java Servlet container, it must follow the rules, but it tries to avoid adding extra complexity. All Vaadin applications are deployed as Java web applications, which can be packaged as WAR files. For a detailed tutorial on how web applications are packaged, please refer to any Java book that discusses Servlets. Sun has an excellent reference online at http://java.sun.com/j2ee/tutorial/1_3-fcs/doc/WCC3.html . To deploy an application to a web server, you need to create a WAR package. Here we give the instructions for Eclipse. Open project properties and first set the name and destination of the WAR file in Tomcat tab. Exporting to WAR is done by selecting from in project context menu (just click calc with the right mouse button on ). The following files are required in a web application in order to run it. Web application organization
The deployment descriptor is an XML file with the name Example 4.1. web.xml <?xml version="1.0" encoding="UTF-8"?>
<web-app
id="WebApp_ID" version="2.4"
xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<servlet>
<servlet-name>myservlet</servlet-name>
<servlet-class>
com.vaadin.terminal.gwt.server.ApplicationServlet
</servlet-class>
<init-param>
<param-name>application</param-name>
<param-value>MyApplicationClass</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>myservlet</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
</web-app> The descriptor defines a servlet with name The Notice also that if the URL pattern is other than root ...
<servlet-mapping>
<servlet-name>myservlet</servlet-name>
<url-pattern>/myurl/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>myservlet</servlet-name>
<url-pattern>/VAADIN/*</url-pattern>
</servlet-mapping> You do not have to provide the above For a complete example on how to deploy applications, see the demos included in the Vaadin installation package, especially the Deployment descriptor can have many parameters and options that control the execution of a servlet. You can find a complete documentation of the deployment descriptor in Java Servlet Specification at By default, Vaadin applications run in debug mode, which should be used during development. This enables various debugging features. For production use, you should have put in your <context-param> <param-name>productionMode</param-name> <param-value>true</param-value> <description>Vaadin production mode</description> </context-param> The parameter and the debug and production modes are described in detail in Section 11.4, “Debug and Production Mode”. One often needed option is the session timeout. Different servlet containers use varying defaults for timeouts, such as 30 minutes for Apache Tomcat. You can set the timeout with: <session-config>
<session-timeout>30</session-timeout>
</session-config> After the timeout expires, the |
Table of Contents
|