tags:

views:

49

answers:

1

HI all! I am working on a JAVA/JSF app that runs within an iFrame. The client authenticates Outside of the iFrame, then redirects back to a page that contains the application inside of an iFrame. If the client has 3rd party cookies disabled, the iFrame will not be able to access the cookie, and it will never see the jsessionid.

What I would like to do is test for the cookie in the app, and if not found, redirect using JS to the current page, with ;jsessionid appended to the end. I tried that with

;jsessionid=#{session.getId()}

Which looked OK...but would never maintain the current session. I then added an

<h:form><h:commandButton/></h:form>

to the page, turned off cookies, viewed the page in a browser, and saw that the jsessionid listed on the form was different than the one provided by session.getId().

My question is this......how can I get the correct jsessionid, the one that would be part of the form?

Thanks! Mason

--Update-- I should mention that this is on the same domain, webserver, and application. an and the #{session.getId()} on the same page will return a different jsessionid at the same time.

A: 

Sessions are by default domain- and context bound. Your issue indicates that the page which the iframe is serving runs at a different domain and/or context.

If the page in the iframe runs at a different domain, then you'll have to write a "local" servlet which acts as a proxy with help of java.net.URLConnection or Apache HttpClient and let the iframe link to that instead.

If the page in the iframe runs at same domain but at a different context (and runs at same webserver), then you need to configure the server to share the same session among all running webapps. How to do that exactly depends on the server in question. If it's Tomcat or a clone/fork, then check the emptySessionPath attribute of the HTTP connector.

BalusC
Thanks for that BalusC. I will look into all of that right now. It is running on the same domain, and same webserver (Jboss AS 5.1).
Mason
oh, and if it's relevant, this is with Apache HTTP in front of the web servers, using AJP (mod_jk) (with sticky sessions)
Mason
To further expand, this is all on the same web application. <h:form><h:commandButton/></h:form> and #{session.getId()} will return a different jsessionid on the same page.
Mason
If it's running at same webapp, why are you using a client side include like `<iframe>` and not a server side include like `<jsp:include>`? As to the different session ID's, aren't you confusing view ID with session ID?
BalusC
This is for a facebook iFrame canvas app, I'm not creating the iframe. I might well be confusing the session ID and view ID, the Session ID is sent as the jessionid in the cookie, or in the URL if their is no cookie support, right? I may well have a fundamental misunderstanding of something here. All I want to do is redirect to the url /page.xhtml;jsessionid=... if cookies are blocked. Should that be the Session ID, or the View ID
Mason