The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

rohitaman0 (2) [Avatar] Offline
#1
Hi,

In my company, we are working on struts 1.1 and I am trying to make GWT and struts work together. I did read some chapters of the book GWT In Action whenever I had some time. I was able to create the server-status component from the book using GWT RPC. It works fine in hosted mode. So, I thought of incorporating the same component in one of the tiles of my jsp page of the struts application.

Now, This component is shown in the jsp when the application loads and everything looks fine. But, It is not able to communicate with the gwt remote servlet on the server using RPC calls.

Can you please give me an idea of what needs to be changed in web.xml for the GWT RPC to work as expected. all I did was to add this

<servlet>
<servlet-name>ServerStatusServlet</servlet-name>
<servlet-class>com.gwtbook.server.ServerStatusImpl</servlet-class>
</servlet>

<servlet-mapping>
<servlet-name>ServerStatusServlet</servlet-name>
<url-pattern>/com.gwtbook.ServerStatus/server-status</url-pattern>
</servlet-mapping>

I did not add anything in struts-config.xml as I do not want the GWT RPC calls to use ActionServlet. But, for some reason, the serverstatus component is not making any calls to the tomcat where this application is running.

can you please brief me on what needs to be done for GWT to wrok with STRUTS.

Thanks in advance
adam.tacy (269) [Avatar] Offline
#2
Re: gwt struts together
Hi,

Struts and RPC can live together, so my first suspect would be a configuration/set-up (especially as you mention it works fine in hosted mode).

>
> Now, This component is shown in the jsp when the
> application loads and everything looks fine. But, It
> is not able to communicate with the gwt remote
> servlet on the server using RPC calls.

Do you get any errors in log files/Browser? Did you get anywhere with Walden's suggestion on the gwt-forum (http://groups.google.com/group/Google-Web-Toolkit/browse_thread/thread/a5bcb845d1261e00/c8337fe964adadcf?lnk=gst&q=struts+rpc#c8337fe964adadcf)?


>
> Can you please give me an idea of what needs to be
> changed in web.xml for the GWT RPC to work as
> expected. all I did was to add this
>
> <servlet>
> <servlet-name>ServerStatusServlet</servlet-name>
>
> servlet-class>com.gwtbook.server.ServerStatusImpl</ser >
> vlet-class>
> </servlet>
> <servlet-mapping>
>
> servlet-name>ServerStatusServlet</servlet-name>
>
> url-pattern>/com.gwtbook.ServerStatus/server-status
> rl-pattern>
> </servlet-mapping>

Have you copied to the server's path the gwt-servlet.jar and the necessary parts of the ServerStatus application?

> But, for
> some reason, the serverstatus component is not making
> any calls to the tomcat where this application is
> running.

Is this Tomcat the same server from where the JavaScript source code is served from? (just making sure there are no cross site issues...)

>
> can you please brief me on what needs to be done for
> GWT to wrok with STRUTS.
>
> Thanks in advance

//Adam
rohitaman0 (2) [Avatar] Offline
#3
Re: gwt struts together
hey thanks for the reply...

I was able to resolve the issue. the problem was with the servlet mapping. Instead of /com.gwtbook.ServerStatus/server-status, I had to use gwt/com.gwtbook.ServerStatus/server-status because I had put the javascript in gwt folder...

thanks
s71211 (1) [Avatar] Offline
#4
Re: gwt struts together
Hi rohit..
Even i am also planning to use GWT in my struts application.Can u please tell me steps to integrate gwt with existing struts.I mean i should be able to make calls from gwt to struts and vice versa...
robert.hanson (173) [Avatar] Offline
#5
Re: gwt struts together
> Hi rohit..
> Even i am also planning to use GWT in my struts
> application.Can u please tell me steps to integrate
> gwt with existing struts.I mean i should be able to
> make calls from gwt to struts and vice versa...

Easy, just add the <script> tag to your HTML page smilie

Seriously, that question is just way too open-ended to provide an answer. If the question is, "can I use GWT-RPC to call a Struts action?", then the answer is NO.

If you need RPC, first look at all of the capabilities of GWT that you need to use. There is GWT-RPC, there is RequestBulder, and there is FormPanel. Then look at the transport options. There is the GWT-RPC serialized data, XML parsing support, JSON support, and in the wild there are implementations of XML-RPC, Comet, and maybe even SOAP.

Next look at what you are trying to accomplish. Then finally choose the right RPC tool for the job.

For me I typically prefer RequestBuilder with JSON, as it is fairly generic, fitting in well with my other technology choices, and has several good Java implementations that I can use on the server... but your specific needs may be different from mine.