Saturday, February 26, 2011

Re: Redirecting to jsp

Not sure if the following is the most elegant way, but it will work as we have done this in our app. I am assuming you want to post to a URL from GWT client to another domain different from your server ( say to a  payment gateway which is why we did this).

1) In your Window.open you call a JSP. Initially you make a HTTP GET to the JSP with all the parameters. 

2) In the JSP, accept all the GET parameters and create a <FORM> with your HTTP GET parameters masqueraded as hidden fields. 

3) In the JSP, have a <BODY onload='submitForm()' >

4) The "submitform javascript" should do "document.formname.submit();"

 
So, the final user experience is, user clicks a button, it opens a new window, a HTTP-GET happens, target JSP spews out a HTML form and a couple of lines of javascript to do the form submit on load. So, a form submit happens. Your GWT APP is unaffected as it is running on a different host page/window. 

Hope this helps.. 

Best Regards
Prashant

On Sat, Feb 26, 2011 at 11:17 PM, Deepak Singh <deepaksingh.kr@gmail.com> wrote:
Any help on this pls.


On Fri, Feb 25, 2011 at 8:58 PM, Deepak Singh <deepaksingh.kr@gmail.com> wrote:
Hi,

In my celltable, i have one button column.
In the fieldAdapter(), i am opening a new window using Window.open(" url", "_blank", "");
It opens a new window withe the url using the http get() method. I want to open this window with http post() method. How can i acheive this ?
I think it is not possible at the client side using java script, so i though it to redirect to a jsp as follows

HttpServletRequest req = getThreadLocalRequest();
HttpServletResponse res = getThreadLocalResponse();
res.addHeader("Referer", "http://www.domain.com");
try {
res.sendRedirect(param);
} catch (IOException e) {
e.printStackTrace();
}


but this does not work. Nothing happens when i click the button.

How it is possible to redirect to a jsp page from gwt?


Thanks

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.

No comments:

Post a Comment