File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Url Rewriting in new browser window Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Url Rewriting in new browser window" Watch "Url Rewriting in new browser window" New topic
Author

Url Rewriting in new browser window

Amit Hetawal
Ranch Hand

Joined: Apr 12, 2008
Posts: 48
Hello All,
I wanted to know what will be the servlet container behavior, when the client has the cookies disabled and it tries to open the same website in a different browser window.

So here is my scenario.
Client sends first request to the servlet, since no cookies set, the container will fallback to Url rewriting and from then on the session is maintained between the client and the server.
But now suppose the client opens a new browser window and tries to access the same link, but without sessionid appended to link, so in this case conatiner will see it as a new client and create a different session for it ?

The point i am getting at is, we say the session objects are not thread safe, because the client can open a new browser window but still it will be in the same session, but i think if the cookies are disabled , then the session objects for that client will be thread safe. is that correct or i am missing anything ?

Please advise.
Balu Sadhasivam
Ranch Hand

Joined: Jan 01, 2009
Posts: 874


But now suppose the client opens a new browser window and tries to access the same link, but without sessionid appended to link, so in this case conatiner will see it as a new client and create a different session for it ?


Nope. For the server it appears to be the request originating from same and only one client.


but i think if the cookies are disabled , then the session objects for that client will be thread safe. is that correct or i am missing anything ?


That's otherwise. two browser with same session access the same session values , so it does means "not thread safe"
Amit Hetawal
Ranch Hand

Joined: Apr 12, 2008
Posts: 48


Nope. For the server it appears to be the request originating from same and only one client.



Am confused how does the server know it is same client, we dont send any kind of id for that client at such.

Balu Sadhasivam
Ranch Hand

Joined: Jan 01, 2009
Posts: 874



Am confused how does the server know it is same client, we dont send any kind of id for that client at such.


The URL has session id in it . that's the concept of URL rewriting.
Vishwanath Krishnamurthi
Ranch Hand

Joined: Jun 04, 2007
Posts: 331
Hi Amit,

I'd like to program and understand that sometime... Maybe you too could try...

1) Disable cookies (See here)

2) Code based on url rewriting.

3) Create a session counter by implementing HttpSessionListener

I have created a Session counter before:



4) Then test the case you thought of.

Regards,
Vishwa


Blog
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Url Rewriting in new browser window
 
Similar Threads
Is session object thread safe.
URL ReWriting
How to find that Cookies are supported by the browser or not
Http Session Attributes are Thread safe
Session attributes' thread safety