Tomcat"

From Documentation
 
(32 intermediate revisions by 4 users not shown)
Line 1: Line 1:
 
{{ZKInstallationGuidePageHeader}}
 
{{ZKInstallationGuidePageHeader}}
 +
=Install Tomcat=
 +
#Visit [http://tomcat.apache.org/ Tomcat Official Site]
 +
#Select the correct binary distribution for your environment and download
 +
#* For Windows, you might download and execute [http://apache.stu.edu.tw//tomcat/tomcat-6/v6.0.29/bin/apache-tomcat-6.0.29.exe 32-bit/64-bit Windows Service Installer], and then follow the instructions
 +
#* Any download/install problem, please refer to http://tomcat.apache.org/tomcat-6.0-doc/index.html
  
=Install Tomcat=
+
=Deploy=
  
* First, visit http://tomcat.apache.org/download-60.cgi
+
==Deploy ZK demo application(optional)==
* Second, select the correct binary distribution for your environment.
 
** Windows users could select "32-bit/64-bit Windows Service Installer" and then follow its instructions.
 
  
=Test drive with the ZK demo application=
+
The simplest way to test drive ZK existed application is to download and install the ZK demo application.
  
The simplest way to test drive ZK is to download and install the ZK demo application.
+
''This step is optional. You could skip it if you prefer to start creating your own application directly.''
  
# Download at http://sourceforge.net/projects/zk1/files/ZK/zk-5.0.4/zk-demo-5.0.4.zip/download<ref>It is recommended to visit http://www.zkoss.org/download/zk.dsp for the most updated version.</ref>
+
# Download the lastest zkdemo at http://sourceforge.net/projects/zk1/files/ZK/ (e.g. zk-sandbox-6.0.0.zip)
# Unzip zk-demo-5.0.4.zip
+
# Unzip zk-sandbox-6.0.0.zip
# Copy the zk-demo-5.0.4 directory to $TOMCAT_HOME/webapps. $TOMCAT_HOME is the directory you installed Tomcat, for example, C:\Program Files\Apache Software Foundation\Tomcat 6.0.
+
# Copy '''zkdemo.war''' under the <u>zk-sandbox-6.0.0</u> directory to $TOMCAT_HOME/webapps.
# Then, you could visit http://localhost:8080/zk-demo-5.0.4 and play around with the demo application
+
# Start/ReStart the tomcat services (In some cases, you may need to restart your container if it is running.)
 +
# Visit http://localhost:8080/zkdemo, and then play around with the demo application
  
 
<blockquote>
 
<blockquote>
 
----
 
----
<references/>
+
Deploy war file to Tomcat is very easy but there're something you need to know
 +
*Tomcat will unzip the war file to <u>filename\</u> directory automatically
 +
*You can ''NOT'' modify the content of <u>filename\</u> directory unless you remove the war file, or your modification will not work.
 +
*For more information about Tomcat's deployer, please refer to http://tomcat.apache.org/tomcat-6.0-doc/deployer-howto.html
 
</blockquote>
 
</blockquote>
  
=Create your first application=
+
==Deploy your application with IDE==
 
 
Here is how to create a Web application manually without IDE or other tools. It is easy to find the similar procedure with your preferred IDE or tools, such as Eclipse and NetBeans.
 
 
 
==Download ZK==
 
 
 
First, download the ZK libraries from http://www.zkoss.org/download/zk.dsp and save it to a proper location.
 
 
 
==Create a Web application==
 
 
 
Creating a Web application in Tomcat is easy: just create a directory under $TOMCAT_HOME/webapps.  $TOMCAT_HOME is the directory you installed Tomcat, for example, C:\Program Files\Apache Software Foundation\Tomcat 6.0.
 
 
 
Let us assume the application is called myZK. Then, the directory structure shall be as follows.
 
 
 
:myZK
 
::WEB-INF
 
::WEB-INF/lib
 
 
 
==Deploy ZK libraries==
 
  
# Unzip zk-bin-5.0.4.zip
+
When developing an application, we usually use IDE to deploy it. For more information, please refer to the document of your IDE.
# Copy JAR files under dist/lib to $TOMCAT_HOME/webapps/myZK/WEB-INF/lib
 
  
==Create web.xml==
+
If you are new to Java IDE, you might take a look at [[ZK_Installation_Guide/Setting_up_IDE/Eclipse_with_ZK_Studio|Setting up Eclipse with ZK Studio]].
 
 
Create web.xml under $TOMCAT_HOME/webapps/myZK/WEB-INF, and Copy the following content into web.xml.
 
 
 
<syntax lang="xml">
 
<?xml version="1.0" encoding="UTF-8"?>
 
 
 
<web-app 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">
 
 
 
<description><![CDATA[My ZK Application]]></description>
 
<display-name>MyApp</display-name>
 
 
 
<listener>
 
<description>ZK listener for session cleanup</description>
 
<listener-class>org.zkoss.zk.ui.http.HttpSessionListener</listener-class>
 
</listener>
 
<servlet>
 
<description>ZK loader for ZUML pages</description>
 
<servlet-name>zkLoader</servlet-name>
 
<servlet-class>org.zkoss.zk.ui.http.DHtmlLayoutServlet</servlet-class>
 
 
 
<init-param>
 
<param-name>update-uri</param-name>
 
<param-value>/zkau</param-value>
 
</init-param>
 
<load-on-startup>1</load-on-startup>
 
</servlet>
 
<servlet-mapping>
 
<servlet-name>zkLoader</servlet-name>
 
<url-pattern>*.zul</url-pattern>
 
</servlet-mapping>
 
<servlet-mapping>
 
<servlet-name>zkLoader</servlet-name>
 
<url-pattern>*.zhtml</url-pattern>
 
</servlet-mapping>
 
<!-- Optional. Uncomment it if you want to use richlets.
 
<servlet-mapping>
 
<servlet-name>zkLoader</servlet-name>
 
<url-pattern>/zk/*</url-pattern>
 
</servlet-mapping>
 
-->
 
<servlet>
 
<description>The asynchronous update engine for ZK</description>
 
<servlet-name>auEngine</servlet-name>
 
<servlet-class>org.zkoss.zk.au.http.DHtmlUpdateServlet</servlet-class>
 
</servlet>
 
<servlet-mapping>
 
<servlet-name>auEngine</servlet-name>
 
<url-pattern>/zkau/*</url-pattern>
 
</servlet-mapping>
 
 
 
<welcome-file-list>
 
<welcome-file>index.zul</welcome-file>
 
<welcome-file>index.zhtml</welcome-file>
 
<welcome-file>index.html</welcome-file>
 
<welcome-file>index.htm</welcome-file>
 
</welcome-file-list>
 
</web-app>
 
</syntax>
 
 
 
=Create your application=
 
 
 
After setting up web.xml, it is ready to serve your application.
 
 
 
For example, we can create a simple page, say, hello.zul with the following content.
 
 
 
<syntax lang="xml">
 
<window title="My First window" border="normal">
 
    Hello, World!
 
</window>
 
</syntax>
 
 
 
Then, you can see the result by visiting <tt>http://localhost:8080/myZK/hello.zul</tt><ref>Assumes Tomcat's port is 8080 and started.</ref>.
 
 
 
<blockquote>
 
----
 
<references/>
 
</blockquote>
 
  
 
=Version History=
 
=Version History=
 
+
{{LastUpdated}}
 
{| border='1px' | width="100%"
 
{| border='1px' | width="100%"
 
! Version !! Date !! Content
 
! Version !! Date !! Content

Latest revision as of 01:58, 21 March 2012


Install Tomcat

  1. Visit Tomcat Official Site
  2. Select the correct binary distribution for your environment and download

Deploy

Deploy ZK demo application(optional)

The simplest way to test drive ZK existed application is to download and install the ZK demo application.

This step is optional. You could skip it if you prefer to start creating your own application directly.

  1. Download the lastest zkdemo at http://sourceforge.net/projects/zk1/files/ZK/ (e.g. zk-sandbox-6.0.0.zip)
  2. Unzip zk-sandbox-6.0.0.zip
  3. Copy zkdemo.war under the zk-sandbox-6.0.0 directory to $TOMCAT_HOME/webapps.
  4. Start/ReStart the tomcat services (In some cases, you may need to restart your container if it is running.)
  5. Visit http://localhost:8080/zkdemo, and then play around with the demo application

Deploy war file to Tomcat is very easy but there're something you need to know

  • Tomcat will unzip the war file to filename\ directory automatically
  • You can NOT modify the content of filename\ directory unless you remove the war file, or your modification will not work.
  • For more information about Tomcat's deployer, please refer to http://tomcat.apache.org/tomcat-6.0-doc/deployer-howto.html

Deploy your application with IDE

When developing an application, we usually use IDE to deploy it. For more information, please refer to the document of your IDE.

If you are new to Java IDE, you might take a look at Setting up Eclipse with ZK Studio.

Version History

Last Update : 2012/03/21


Version Date Content
     



Last Update : 2012/03/21

Copyright © Potix Corporation. This article is licensed under GNU Free Documentation License.