• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

HFSJ Final Mock Question 47

 
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Which statements about HttpSession objects are true?


A.
B.
C.
C.
E. A user who access the same web application from two broser windows is guaranteed to have two distinct session objects.

The explaination says E is invalid becasue multiple browser windos will typically share a session.

But when I following in two browser windows, I see two different JSESSIONID. How to explain that?
============
<%
Cookie cookie = new Cookie ("username","Grace");
cookie.setMaxAge( 24 * 60 * 60);
response.addCookie(cookie);
%>

<br>
<%=request.getHeader("Cookie")%>

Thanks.
 
Grace Yang
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
anybody can help me on this?

Thanks
 
Ranch Hand
Posts: 185
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It is true that a session is shared between two browser windows BUT only if the browser is the same.

If suppose you log into an application in IE then a session is created for you. Now if you open another IE window this session is shared. Becasue the cookie storehouse of IE is shared.

But suppose if you open FireFox then browse to your application then the application will have no idea who the user is since Firefox has its own cookie storehouse. So it will create a new session object with a different ID than earlier.
 
Grace Yang
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks nitin for replying.

But..
I am using IE browser, and I see different cookie values when I run my app in 2 seperate IE browsers.

Grace
 
pie sneak
Posts: 4727
Mac VI Editor Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Multiple windows can share the same session IF the second window was spawned from the first window participating in a session.

This can happen if a request is sent from the first window with a different target or by the user cloning the first window with something like Ctrl+N in IE.
 
Grace Yang
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank Marc.

I tried to open 2nd one using <Ctrl> N, you're right about session sharing.

But the last option of the question does not state how broswer should be opened, so should I assum that author has the implication that seperate windows will be opend by this way?

Thanks
 
nitin pai
Ranch Hand
Posts: 185
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Marc Peabody:
Multiple windows can share the same session IF the second window was spawned from the first window participating in a session.

This can happen if a request is sent from the first window with a different target or by the user cloning the first window with something like Ctrl+N in IE.




But Marc,
I believe session is not destroyed just by closing a browser window. So if the session is still alive even if i close the browser for a second and re open it the session should still be the same. Isn't it so?

And even I don't think that the session is shared only if the parent window spawns another window. Eventually session will be stored as cookies (except for cookies disabled). So any new instance of the browser must share the same JSESSIONID. Am I right?
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic