Apache Tomcat is the name in JSP, and you’ll need to get a copy before being able to try out the many cool web applications and frameworks out there (like ZKoss’s ZK). Finding a development need to run JSP pages (and wanting to try out ZK), I decided to get the latest Tomcat version (6.0.18) installed, and give you the scoop on getting it up and running. It is a pretty easy install, you just need to have Java 6. If you are running Ubuntu, the easiest way is to run a simple apt-get install:
$ sudo apt-get install sun-java6-jdk
I really like to have full control over my development environments, so I’m not going to grab Tomcat using apt (besides, I said the latest version). Go ahead and grab a zipped copy of the core distribution from the Tomcat website. Now that you have the latest and greatest lets unzip the contents of your .zip into a /usr/local/tomcat folder.
~$ unzip apache-tomcat-6.0.18.zip ~$ sudo mv apache-tomcat-6.0.18 /usr/local/tomcat
Now, before we can start the Tomcat server, we’ll need to make some of the script files executable (note: if you downloaded the tar.gz archive instead, these scripts might already have the executable bit on. To avoid any potential snags, I’d issue these regardless of which compressed file you downloaded).
~$ cd /usr/local/tomcat/bin ~$ sudo chmod +x *.sh
Since I’d like to check out the neat framework demo ZK has, I need to be able to deploy their WAR in my webapps. To make deploying point and click, I’ll be using the Tomcat Manager. If you want to use the Tomcat Manager you’ll need to modify the users and roles specified in the tomcat-users.xml file located in the /usr/local/tomcat/conf folder. Modify this xml file to have something similar to what is below. Be sure to change username to something more creative and change the password (I don’t suggest using your real password considering this is a flat file). The file should contains something like this;
<tomcat-users> <role rolename="manager"/> <role rolename="tomcat"/> <role rolename="admin"/> <user username="codenomad" password="supersecret" roles="tomcat,admin,manager"/> <user username="admin" password="secret" roles="manager,admin"/> </tomcat-users>
That should just about do it. Let’s start up the server by running:
~$ sudo /usr/local/tomcat/bin/startup.sh
You can test your install by clicking here. You should see something like this:
If you need to shutdown the server you can issue a similar command:
~$ sudo /usr/local/tomcat/bin/shutdown.sh
Now that we have Tomcat installed, lets check out that ZK demo I was talking about. First, you’ll need a couple things. You’ll need the ZK binary and the ZK demo. Download both of those here.
Unzip those files and copy the .jar’s over to your Tomcat library (this will allow you to include all of the greatness that is ZK in your future webapps).
~$ unzip zk-bin-prof-3.5.1.zip ~$ unzip zk-demo-3.5.1.zip ~$ cd zk-bin-prof-3.5.1/dist/lib ~$ sudo cp *.jar /usr/local/tomcat/lib/ ~$ sudo cp ext/*.jar /usr/local/tomcat/lib ~$ sudo cp zkforge/*.jar /usr/local/tomcat/lib
Next, you’ll have to restart your Tomcat server:
~$ sudo /usr/local/tomcat/bin/shutdown.sh ~$ sudo /usr/local/tomcat/bin/startup.sh
Head back to the Tomcat page here, and click on the Tomcat Manager link in the top left. Enter in the username and password you modified in the XML file above, and scroll to the very bottom where it says “WAR file to deploy”. Click browse, and find the zkdemo.war file in the unzipped zk-demo-3.5.1 folder that was unzipped earlier.
Next, click on the Deploy button. You should see that the zkdemo is now in the Applications list, and if you click on the link that Tomcat provides you’ll get a welcome screen:
Thats it! You have a fully functional Tomcat Server, and you can start developing with the ZK platform! Check out ZK’s site for more development information. Good luck, and happy coding!