This article will use Apache Tomcat as the sample servlet container because it is widely available and free of charge. Other servlet containers behave similarly. Typically, it will be deployed to an existing server, but if not, the links in the Resources section at the end of this article will tell you where to download Tomcat. If you are running the microsoft®windows® operating system, Tomcat has a relatively easy-to-use Windows-oriented binary installer. If it is on a Mac or UNIX® system, there is a compiled version that can be extracted and placed in a convenient location (usually/usr/local), and you can continue to learn after setting up some environment variables.
Edit client Code
Broadly speaking, there are two steps to deploying a GWT application in Tomcat:
Collect all the necessary files and place them in a location that Tomcat can view.
Make Tomcat aware of all server-side operations that are invoked from the GWT page.
The process is a few steps ahead of the assumption, and there is no official way to automate these steps by the time this article is finalized. I describe the manual process here. However, when you read this article, there may already be more robust tools to support deployment.
Navigate to Tomcat's installation root directory. In the next level of the directory, you will see a subdirectory named WebApps. Each application running within the Tomcat servlet container will get a directory of the application itself from there. Therefore, a directory named SLICR is created within the WebApps. The structure of the Java server-side application is set in accordance with the servlet standard, and all servlet running programs should support the same structure.
In the SLICR directory, create a subdirectory named Web-inf-yes, make sure to capitalize.
Move the GWT-compiled JavaScript page and the normal compiled Java class to the SLICR directory. I'll show you how to create Java classes first.
Compile Java code normally using the Integrated development environment (IDE), Apache Ant, or the tool you want to use. There are many choices at this time:
The quickest option is to copy the entire. class file tree to the Tomcat subdirectory webapps/slicr/web-inf/classes, where Tomcat will automatically place the CLASSPATH variable of the WebApps directory into that subdirectory.
Alternatively, you can use your favorite tool to convert the compiled class to a jar file, and then put the jar file into the Webapps/slicer/web-inf/lib directory. In addition, Tomcat puts the JAR file into the directory of the CLASSPATH variable.