Http Headers

133 views
Skip to first unread message

AP

unread,
Dec 10, 2010, 3:54:18 PM12/10/10
to Google Web Toolkit
I have just started on the GWT 2.1 application. We have a single sign
on done by a tool that passes the credentials in the HTTPHeader. Based
on the credentials, different users need to be directed to different
landing pages. How can I get a handle to the httpheader information in
my gwt application.

skrat

unread,
Dec 10, 2010, 4:18:10 PM12/10/10
to google-we...@googlegroups.com

AP

unread,
Dec 10, 2010, 4:41:41 PM12/10/10
to Google Web Toolkit
Thanks for the response. May be I am missing something but this class
seems to be for making a Get request. To add some more information, I
have a spring + gwt application.

On Dec 10, 3:18 pm, skrat <dusan.malia...@gmail.com> wrote:
> http://google-web-toolkit.googlecode.com/svn/javadoc/2.1/com/google/g...,
> java.lang.String)

skrat

unread,
Dec 10, 2010, 4:51:21 PM12/10/10
to google-we...@googlegroups.com
I assume you mean Spring Roo + GWT? In that case I can't help you, heard of it before but never used it, quickly checked it out, seems like lots of scaffolding is going on there, so you will have to customize. RequestBuilder class can make requests of any method btw (as long as browser supports that).

PeteUK

unread,
Dec 11, 2010, 4:55:24 AM12/11/10
to Google Web Toolkit
This post intrigued me so I had a look around. As GWT client code will
be Javascript, I searched for how to access the HTTP headers in
Javascript. I found this: http://stackoverflow.com/questions/220231/accessing-http-headers-in-javascript
which doesn't sound like you can.

Theoretically there might be something added into GWT to facilitate
it, but I couldn't find it.

Pete

skrat

unread,
Dec 11, 2010, 12:47:09 PM12/11/10
to google-we...@googlegroups.com
There is already support for HTTP headers in XHR in GWT, it's the method I posted. And it works with all major browsers. The problem I guess is that you probably have issues with using RequestBuilder class from your Spring Roo app.

PeteUK

unread,
Dec 11, 2010, 1:03:46 PM12/11/10
to google-we...@googlegroups.com
On Saturday, December 11, 2010 5:47:09 PM UTC, skrat wrote:
There is already support for HTTP headers in XHR in GWT, it's the method I posted. And it works with all major browsers. The problem I guess is that you probably have issues with using RequestBuilder class from your Spring Roo app.

I thought the OP was trying to get the HTTP response headers of the request that served the hosting page of his/her GWT app.

But reading their message again, they mention different landing "pages". If they want to serve a different page then that's a pure server-side/Spring issue. If they want to have different pages in their GWT app based on the HTTP headers used to serve up the hosting page, then I'm not sure they can do it easily.

Thanks,

Pete

P.S. They never mentioned Roo.

AP

unread,
Dec 11, 2010, 6:51:28 PM12/11/10
to Google Web Toolkit
We are not using Spring Roo. The problem is as follows

1. User provides credentails to login to a portal.
2. An existing portal verifies the credentials. Reads LDAP and grabs
more information about the user.
3. This info is added to the Http header and the http request is to
be forwarded to the new GWT app.
4. The GWT app needs to read a the header and different users will
land on different pages.

I was hoping that there would be a way to read the HTTP header and
decide which page to serve the user.
It seems to me that I will have to intercept the request in an servlet
and let the servlet decide where the user need to in the app.

Thanks
AP

PeteUK

unread,
Dec 11, 2010, 7:06:24 PM12/11/10
to google-we...@googlegroups.com


On Saturday, December 11, 2010 11:51:28 PM UTC, AP wrote:
We are not using Spring Roo. The problem is as follows

1. User provides credentails to login to a portal.
2. An existing portal verifies the credentials. Reads LDAP and grabs
more information about the user.
3. This info is added to the Http header and the http request is to
be forwarded to the new GWT app.
4. The GWT app needs to read a the header and different users will
land on different pages.

I was hoping that there would be a way to read the HTTP header and
decide which page to serve the user.
It seems to me that I will have to intercept the request in an servlet
and let the servlet decide where the user need to in the app.


When you say land on different pages, you mean different HTML pages? Are these different pages all hosts for the same GWT app? It definitely sounds like something you'd want to do server-side otherwise there'll be a page presented after logon which loads a GWT application, all just to be redirected to a different page. Is there a reason you prefer to code this logic in the client?

If you mean there's just one page after login but depending on the user the GWT app will present a different "screen", then that's a different problem and something you could communicate (but HTTP headers wouldn't be the vehicle of choice).

Thanks,

Pete

cri

unread,
Dec 11, 2010, 7:37:56 PM12/11/10
to Google Web Toolkit
Pete,

I am on the same team as poster. The situation we refer to is the
latter of the two you mention, i.e. based on the users permissions, we
will present one of several GWT views/screens. If we can't do this by
accessing HTTP request headers (it seems strange that there isn't a
way to do this), how can it be done? Thanks

Chuck

PeteUK

unread,
Dec 11, 2010, 7:56:31 PM12/11/10
to google-we...@googlegroups.com


On Sunday, December 12, 2010 12:37:56 AM UTC, cri wrote:
Pete,

I am on the same team as poster. The situation we refer to is the
latter of the two you mention, i.e. based on the users permissions, we
will present one of several GWT views/screens. If we can't do this by
accessing HTTP request headers (it seems strange that there isn't a
way to do this), how can it be done? Thanks



Chuck,

I think you have at least two options open to you.

1) Write data into the hosting HTML page that the GWT app can access. Not sure on the best elements to choose - perhaps a <form> without hidden field(s) and no submit button? I think the GWT app would be able to access these elements using RootPanel.get("theId"). A criticism of this method would be the visibility of it to an end-user who views the source of the page.

2) Set a "usertype" cookie in the server. This can be inspected by the GWT app.

Caveat: I'm a newbie to this (haven't started my own project - still getting to grips with development environment).

Thanks,

Pete


PeteUK

unread,
Dec 11, 2010, 7:57:21 PM12/11/10
to google-we...@googlegroups.com
s/without hidden/with hidden

Myles Bostwick

unread,
Dec 13, 2010, 12:00:10 PM12/13/10
to google-we...@googlegroups.com
Another less optimal option is to let the webserver handle the redirection based on the HTTP headers, via some sort of extension. Or instead of writing HTTP headers you could write to the the URL and just use some sort of Rewrite rule. 

Thomas Broyer

unread,
Dec 13, 2010, 1:56:31 PM12/13/10
to google-we...@googlegroups.com

PeteUK

unread,
Dec 15, 2010, 5:40:39 AM12/15/10
to google-we...@googlegroups.com
On Monday, December 13, 2010 6:56:31 PM UTC, Thomas Broyer wrote:
See also: http://code.google.com/webtoolkit/articles/dynamic_host_page.html

That's a great page. Introduces the method of servlet writing a javascript variable which is much better than the hidden form variables or cookie methods I proposed. This is something I'll be doing shortly too, so thanks!

Pete
Reply all
Reply to author
Forward
0 new messages