aspose file tools*
The moose likes JSP and the fly likes frames and pageContext Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "frames and pageContext" Watch "frames and pageContext" New topic
Author

frames and pageContext

Brusk Baran
Ranch Hand

Joined: Nov 15, 2001
Posts: 132
say there are 5 frames, each accessing some jsp pages, even to the same jsp page but with different parameters and forwarded.
Their pageContext are different! ok?
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12675
    
    5
That is correct - the "page" context exists only with a single JSP and request.
Bill
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60050
    
  65

When using frames it's important to remember that each frame is its own window. Despite the fact that the browser groups them together to appear as a single page to the user, they are not different from the server's point of view than multiple browser windows.
bear


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Brusk Baran
Ranch Hand

Joined: Nov 15, 2001
Posts: 132
But their sessions (if any) are the same???
Brusk Baran
Ranch Hand

Joined: Nov 15, 2001
Posts: 132
0OK I c..
They are each in fact an individual browser window, but since the session Cookie is normally set with the domain name as host target, each of these framed jsp pages will send the same cookie created by any of the framed jsp pages. SO in effect they share the same session........ thx...
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12675
    
    5
Also important to note that since each frame causes a separate request, there could well be multiple request Threads trying to work with session variables "at the same time" - you may have to synchronize access.
Bill
Brusk Baran
Ranch Hand

Joined: Nov 15, 2001
Posts: 132
Hoi William,
actually I am using JavaScript to force the other frames location.href to be replaced also. In fact they all are forwarded to the same ctroller.jsp page , but with different parameters.
so request is different but session is the same. You are right, I must synchronize the session based code parts.
But do you know which frame gets forwarded to the server first? in order or is it browser specific?
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12675
    
    5
I don't think you can rely on the browser to follow a particular order - that sounds like a job for your JavaScript. I suspect you will have to get tricky with Javascript to ensure that Frame 1 has gotten a complete page before sending the request for Frame 2 - its an interesting problem.
Bill
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60050
    
  65

The only way to ensure order is to fire off a "chain" by updating subsequent frames in the onLoad handlers of each frame. Messy.
bear
Brusk Baran
Ranch Hand

Joined: Nov 15, 2001
Posts: 132
I must just ensure that the login frame, which will later cause a session to be created to be sent first. so that the server knows the domain name of the Cookie he just creates and handles the other frames' request according to this session.
OR must I really ensure that the login frame response be sent to the client , and then send send the first requests of the other frames??
what is the way? Must the cookie be sent by the browser? or if a session cookie has been already created on the server side? does that suffice that the existence of a session?
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12675
    
    5
The cookie Id value that identifies the session absolutely must be set by a response sent to the browser BEFORE any other requests. Otherwise each request may cause creation of a new session and cookie Id value.
Can you have a simple initial request/response cycle before loading the individual frames? That could be the request that created the FRAMESET.
Bill
Brusk Baran
Ranch Hand

Joined: Nov 15, 2001
Posts: 132
I cannot set the session @ the first request which is to the index.jsp (the main frameset containing 4 frames: top, corner, navigate [=login],and main).
B'cos the client must sign on with a logname and password.
Q1. Is it the happening, that the same site might have different sessions for a unique host, @ the same time? It shouldn't.then no problem, but otherwise:
Q2: if it can, then my solution will be : send request to the server with the left frame window only... Donot send the other frames anyhow with js. and when he logs on successfully, get the session in the left.jsp & on its code add (if session!==null)---> execute some javascript code which will change the locations of the other frames , with some from session retrieved parameters also: say self.parent.mainFrame.location.href=some-RelativeURL?parX=<%=session.getX.toString()%>&parY=vvv&lang=fr&..... I hope this will work. I will create a test situation as soon as possible.
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12675
    
    5
You are on the right track. Why not have the other initial frames loaded with static pages just so they won't look odd and disturb the customer.
Let us know how it works out.
Bill
Brusk Baran
Ranch Hand

Joined: Nov 15, 2001
Posts: 132
Hi William, it works fine.
Just I am writing the specs and also at the same time implementing new functionality for an already existing application; they already have a login facility and have many frames etc.
The login that will be added by me is an extension. for ex. ne can log in as an existing user, as my extended login which are two different logins; and also login as both, one by one I mean.
so on the left frame(where the two different login name/passwd boxes will be simultaneously existing), there is still a lot to do.
Existently there are horrible Layers, which make my work very difficult to integrate the new functionalities, without disturbing the working schema:
The existing JavaScript functions, layers, and frames are all coupled with each other. I guess writing the whole application from scratch would be better from my side, but unfortunately the business doesnot agree. They think it is piece of cake to add this utility.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: frames and pageContext
 
Similar Threads
What's the difference between ServletRequest and PageContext?
Cannot make a static reference to the non-static method setAttribute from the type JspContext
Frames in JSP
difference in forwarding using PageContext.forward and RequestDispatcher.forward
Page context encapsulation