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.

PayamFard (23) [Avatar] Offline
#1
Hi all,

I have a regular servlet and some GWT code. What I would like to do is to redirect to the GWT html generated page at the end of my doPost method.

For some reson when I do:

response.redirect("http://.../page.html"); the html page does not get rendered!

If I access the above URL directly, html comes up fine and the GWT AJAX calls are getting executed fine.

Any thoughts on what could be wrong here?

Thanks in advance,
Payam
robert.hanson (173) [Avatar] Offline
#2
Re: Redirecting to a GWT html generated page from a servlet
You weren't explicitly clear, but it sounds like you are trying to do a redirect as part of an RPC call (RequestBuilder/GWT-RPC), correct?

Realize that in the case of an Ajax request, it isn't the main browser window making the call, so the main browser will never be effected by the response, redirect or otherwise.

What you need to do is handle this on the client side. Have the RPC call return the URL of the redirect, then use Window.open() on the client with "" as the window name.
PayamFard (23) [Avatar] Offline
#3
Re: Redirecting to a GWT html generated page from a servlet
Thanks Robert for your response.

I am not trying to redirect as part of an RPC call. At the end of the doPost method of my regular servlet (and not my GWT servlet), I do response.redirect("http://.....html"); to the gwt html generated code. Now once the html comes up, it make some async RPC calls, but redirect is occurring as a sync call inside the regular servlet.
robert.hanson (173) [Avatar] Offline
#4
Re: Redirecting to a GWT html generated page from a servlet
I am not sure I understand then. If you are making the call to the server via HttpRequest, RequestBuilder, XMLHTTPRequest, FormPanel, or GWT-RPC, these can all be considered RPC calls, and none of these will handle a redirect from the server in the fashion you are expecting. You need to do this on the client-side, it cannot be done from the server.

I am actually hard pressed to think of any ways to access the server from GWT that would in fact honor a client-side redirect.