views:

483

answers:

2

I currently have a primary Java Web App Project which houses some Servlets, JSPs and static HTML pages. Later on, I also created a second Eclipse Google Web Toolkit Project (GWT). Now, after finishing the GWT Project, I want to integrate or merge the GWT Project (while retaining its RPC capabilities with Servlets) with the Primary Java Web App Project. In which directory do I need to copy-paste the files and folders from GWT Project to Java Web App Project? Keep in mind that I want to export the fully compiled JavaScript code rather than Java byte code.

A: 

If you only want to move the compiled javascript code, put it under a public access directory: i.e.

web-root/www
Aito
But what about RCP? How do I make the JavaScript App to talk with a Servlet? I want to deploy it to a Web Container, not a Web Server.
Catfish
+1  A: 

You can put all the Java files from your GWT project exactly where they were in the GWT project. I think your gwt.xml file can stay the same also. In your web.xml file, you'll need to define the servlet(s) that you use in GWT, for example if gwt.xml has <servlet path="/MyService" class="com.catfish.server.MyServiceImpl"/> then web.xml will need:

<servlet>
  <servlet-name>MyService</servlet-name>
  <servlet-class>com.catfish.server.MyServiceImpl</servlet-class>
</servlet>

and

<servlet-mapping>
  <servlet-name>MyService</servlet-name>
  <url-pattern>/module-path/MyService</url-pattern>
</servlet-mapping>

Then use an ant build script to compile the GWT into WebContent/module-path. You can still run your GWT project using the GWT standalone browser, but when you want to run everything together, you'll compile the GWT project and then run Tomcat or Jetty or whatever servlet engine you're using. And you'll need to put the path to your generated GWT JavaScript app in whatever JSP or static page uses it.

Brian Deterling