aspose file tools*
The moose likes Servlets and the fly likes request.setAttribute in firefox Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "request.setAttribute in firefox" Watch "request.setAttribute in firefox" New topic
Author

request.setAttribute in firefox

Neeraj Vij
Ranch Hand

Joined: Nov 25, 2003
Posts: 315
Hi,

I want to do the following in firefox browser.

1.) visit page a.jsp. set the value of atrribute a as 12345
2.) display value of a request attribute test in a.jsp. Set the attribute a value to null.
3.) close firefox
4.) open new firefox window and again visit a.jsp.
5.) display value of a request attribute test in a.jsp


I was expecting the value of request attribute in step 5 to be null. But it show the value 12345.

Kindly inform, how can this be solved.



I also tried by putting the following code at the top of jsp



Thanks,
Neeraj.
Aneesh Vijendran
Ranch Hand

Joined: Jun 29, 2008
Posts: 125
First of all, it has nothing to do with Browser, because anything inside

<% & %> happens inside the server.

So what's the problem you get here?

Are you getting an exception here?



Cheers
Aneesh
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9293
    
  17

Aneesh Vijendran wrote:Are you getting an exception here?

There won't be any exception here. request.getAttribute("token") will return null and null can be type casted to String.

Neeraj, you are not displaying the value of token attribute to the client i.e. the browser. So how are you actually able to see 12345 in the browser...


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
swapnl patil
Ranch Hand

Joined: Aug 13, 2007
Posts: 80


In this code first you set the vale to 12345 then you are setting the value to null so result should be

token before setting it to null --->12345 setting token to null ---> token after setting it to null --->null

try this code





I am getting the same result each time

token before setting it to null --->12345 setting token to null ---> token after setting it to null --->null


Neeraj Vij
Ranch Hand

Joined: Nov 25, 2003
Posts: 315
My Apologies. I put the incorrect order of statements..



Also do the following steps-

1.) Open firefox 3.5 and open the jsp containing the above code. Observe the log
2.) Open NEW INSTANCE of fire fox 3.5 and open google.com
3.) Close the window opened in step 1.
4.)Open NEW INSTANCE of fire fox 3.5 and open the jsp opened in step 1. Observe the log.


line System.out.println("token on loading the page -->" + (String)request.getAttribute("token")); at step 4 still retains the value of the token even after the window has been closed in step 3.

Fire fox window retains request and session attribute values even if window is closed if you don't log out.

This is a know issue with Fire fox. Earlier this was happening even with out performing the step 2. We were able to solve the issue at web server level. Now the issue is happening if we perform step 3.

You can also observe this issue with your yahoo and gmail email accounts.

1.) login into yahoo/gmail email accounts using fire fox 3.5
2.) close window
3.) open yahoo/gmaill email account page. it will directly log you in.

I am trying to solve the issue.

Kindly provide any inputs.

Thanks
Neeraj.

Neeraj Vij
Ranch Hand

Joined: Nov 25, 2003
Posts: 315
Hi,

any inputs will be a help.

Thanks,
neeraj
Chinna Eranna
Ranch Hand

Joined: Dec 08, 2009
Posts: 174

That cannot happen. Attributes in the request are at store in only one request/response flow.
Once the page is generated the values in the request are lost.

Also, the <% -- %> gets executed at server.

You can also observe this issue with your yahoo and gmail email accounts.


They achieve this with the cookies. That is not an issue.

You have some other problem in your code.


- Chinna
Neeraj Vij
Ranch Hand

Joined: Nov 25, 2003
Posts: 315
please try out the steps in firefox. I was also surprised. It was even saving the request attributes.
Chinna Eranna
Ranch Hand

Joined: Dec 08, 2009
Posts: 174

Neeraj,

Tell me how does firefox will come to know about request attributes ?
Neeraj Vij
Ranch Hand

Joined: Nov 25, 2003
Posts: 315
I was also surprised the way it behaves. Thats what I am also unable to understand.

You will be able to believe when you could try out the steps given in fire fox 3.5 and then we can discuss more.

many thanks
Neeraj.
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9293
    
  17

I don't know what this thread has to do with struts.
I was also surprised. It was even saving the request attributes.

What did you see in the logs and what actually did you expect?? There is *no* way that firefox can store request attributes. It cannot happen. The thing that might happen is that firefox might not issue a new request when you open the same page again and use the cached version of the page. Also when you say "close the window", do you mean close the window or close the tab??
Fire fox window retains request and session attribute values even if window is closed if you don't log out.
This is a know issue with Fire fox.

There is no "issue" here. Firefox can log you in automatically if the session cookie of the particular site has a fix lifetime i.e. its not deleted when the browser window is closed. As I said earlier, browser has no control over request or session attributes...
Neeraj Vij
Ranch Hand

Joined: Nov 25, 2003
Posts: 315
where did I mention "Struts"..

I meant "Close the window" only.

First please try it out and then share your experience.

There are things out in the world which do exists which you have not seen. So, please be open to learning new things. Don't be stuborn.

please refer the following link.

https://bugzilla.mozilla.org/show_bug.cgi?id=117222

Just to add transient cookies expire with browser closure and not persistent cookies, if you implement it with Siteminder etc.

thanks
Neeraj


Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9293
    
  17

Neeraj Vij wrote:where did I mention "Struts"..

I thought this thread was in struts forum my bad

First please try it out and then share your experience.

There are things out in the world which do exists which you have not seen. So, please be open to learning new things. Don't be stuborn.

Yes, there are a hell lot of things that I've not seen, I hope to have a life long enough to see as many things as I can (joke)

The bug that you are mentioning has nothing to do with what you are saying here (I read the bug report and not all the comments). I tried the exact steps that you told and this is the output in tomcat (which is nothing that I didn't expect)

token on loading the page -->null
setting token to null
token after setting it to null --->null
token on loading the page -->null
setting token to null
token after setting it to null --->null

Looking at that output, how do you think firefox is storing request attributes??
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: request.setAttribute in firefox