HOWTO Make an GWT app and publish it in Tomcat with Eclipse July 27, 2007
First install the latest version of the cypal studio project plug-in.
Making a Cypal Studio Project
File -> New -> Project -> Dynamic Web Project

Title the project and select Cypal Studio CWT Project, then hit Finish.
Importing dynatable example code
One easy way to do this is right click on the new project icon and choose Properties from the pop-up menu.
Choose the Java Build Path from the menu on the left. Then select the Source tab. Click the Link Source... button and find the folder <google tool-kit root directory>/samples/DynaTable/src. Give the imported src folder an apt name like srcDynaTable. Hit OK and your Java Build Path window should look like the one below:

Close this window and the srcDynaTable folder will appear in the tree.
Run DynaTable in Hosted Mode
Now run the application in "Hosted Mode." Open the run menu in Run-> Open Run Dialogue... and configure your run dialogue to look like the one below. ( Your left window will look a little different.)

Hit run, and watch your google app appear in their testing enviornment.
Edit the web.xml file located in the WebContent/WEB-INF folder by double clicking on it.
It should look something like this:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN" "http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">
<web-app id="WebApp_ID">
<display-name>DynaTable</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
</web-app>
Change it to:
<?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>DynaTable</servlet-name>
<servlet-class>com.google.gwt.sample.dynatable.server.SchoolCalendarServiceImpl</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>DynaTable</servlet-name>
<url-pattern>/calendar</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>DynaTable.html</welcome-file>
</welcome-file-list>
</web-app>
Note that this file content is in agreement with the hoasted mode version of this file DynaTable.gwt.xml locaed in srcDynaTable/com.google.gwt.sample.dynatable folder. The <welcome-file-list> tag informs the web server which file should be served when the root directory is choosen.
Now copy the files in the com.google.gwt.sample.dynatable/public which the google faries have placed there when you ran the app in hosted mode into the WebConnect folder.

Configure the Tomcat Server
Install the tomcat plug-in for eclipse. Now select the servers tab in the lower right sub-window. Right click in that space and select new from the pop-up window. Choose the version of Tomcat you are running and hit ok. Now right click on that server and choose "add and remove projects" from the pop-up window. Choose the DynaTable app to be added. Hit OK. Now right click again on the server and start it. 
Your DynaTable project should be hoasted on the tomcat server. To see it go to: http://127.0.0.1:8080/DynaTable/ in your web browser.
No comments:
Post a Comment