aspose file tools*
The moose likes JSP and the fly likes How to invalidate session? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "How to invalidate session?" Watch "How to invalidate session?" New topic
Author

How to invalidate session?

narender kaasam
Greenhorn

Joined: May 15, 2006
Posts: 28
How to invalidate session?. What are techniques used?.
[ May 22, 2006: Message edited by: Bear Bibeault ]
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

The best place to look for questions like this is the API:
http://java.sun.com/j2ee/1.4/docs/api/javax/servlet/http/HttpSession.html


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
geeta lalchandani
Ranch Hand

Joined: Jun 07, 2005
Posts: 118
How to invalidate session?. What are techniques used?.


I guess you meant the ways...
session.invalidate is one
Other is you can specify the timeout in the web.xml.
Parameswaran Thangavel
Ranch Hand

Joined: Mar 01, 2005
Posts: 485
I liked to put one point which i read some where,
The session wont get invalidated when the browser is closed, The session can be invalidated only through Time out property or Session.invalidate method.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61224
    
  66

That is correct. The closing of a browser window has no direct effect upon the session.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Jeff Pollet
Ranch Hand

Joined: Jul 20, 2005
Posts: 49
Metaquestion:
I'm curious about something that I've seen quite often in the various forums: Oftentimes and 'answer' will be in the form of "Look at the API" or even "RTFM". This sort of answer confuses me, because, ultimately, it seems, just about any question could be answered by pouring over the API and trying out various things. One of the reasons that people come to these forums is that they have read the API and are unsure why something they're doing isn't working, or they simply don't 'get' the API for the particular thing they're trying to do.

Certainly, there are questioners who don't bother to look at the API--but I think it's more difficult to tell who they are than others seem to think. What use does "Look at the API" have, as an answer? Everybody knows there is an API, everybody knows that they could look at it--so saying 'look at it' is akin to saying 'that's a bad question'; in many cases, I don't think it is a bad question. If it is a bad question, it takes longer to say "Read the API" than to simply ignore the question. So what is the point?


newbie, please be gentle.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61224
    
  66

Originally posted by Jeff Pollet:
Oftentimes and 'answer' will be in the form of "Look at the API" or even "RTFM". This sort of answer confuses me, because, ultimately, it seems, just about any question could be answered by pouring over the API and trying out various things.


I disagree. There are many questions that transcend the API, especially when it comes to techniques and patterns.

But simplistic question like "how do I trim a string?" or "how do I invalidate a session" are spelled out right there in the javadocs and it's not worth the time of the volunteers who help answer questions here to spend time on a question posed by someone who won't take the time to do even basic research on their own.


One of the reasons that people come to these forums is that they have read the API


Sadly, no.

Certainly, there are questioners who don't bother to look at the API--but I think it's more difficult to tell who they are than others seem to think.


Disagree again. I find them very easy to spot.

What use does "Look at the API" have, as an answer?


Two that I can think of: 1) It tells them that the answer is in the API should they bother to look, and 2) it tells them that JavaRanch is not a code mill or answer farm, but rather that it is a learning site. And learning how to use the javadoc is one of the most useful lessons that can be taught.

if it is a bad question, it takes longer to say "Read the API" than to simply ignore the question. So what is the point?


See (2) above.
[ May 22, 2006: Message edited by: Bear Bibeault ]
Jeff Pollet
Ranch Hand

Joined: Jul 20, 2005
Posts: 49
Sadly, no.

Waitaminute. It's not even one of the reasons that people come to the forums, that they have read the API and don't understand it? That seems relatively unlikely. It's certainly one of the reasons that I have come askign for questions, so I'm at least one countrexample.

As far as letting people know that the forums aren't and answer farm (love that term), wouldn't ignoring their question have the same effect? Plus, I find it difficult to believe that the person who asked this question, for instance, didn't already know that the answer was in the API somewhere...and ignoring his question would have made it pretty clear that this isn't an answer farm.

I guess I'm probably spending too much time thinking about it. Just seems like those of us who might have read the API and just don't understand don't really deserve to be condescended to by pointing to it again...and I do think that in some cases it is intended to be condescending.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61224
    
  66

Originally posted by Jeff Pollet:

Waitaminute. It's not even one of the reasons that people come to the forums


Of course it is. My short reply was not meant to imply that everyone, not even a majority, of posters here don't do their "homework". Just look at some of the excellent threads that take place in this and the other forums. Rather, there are the few who either don't bother and expect others to do their work for them, or -- and this is probably most prevelant -- haven't yet learned how to learn.

For these folks, "please use the javadoc" is an appropriate response. By the way, you'll never see a rude "RTFM" here. If such a rude reply should be posted, someone will make it disappear before too long.

answer farm (love that term)


Thank you. I'll take credit for it.

wouldn't ignoring their question have the same effect?


Not always. For those that need to learn how to use the javadocs as a resource, a bit of direction will go a lot farther than the sound of crickets.

don't really deserve to be condescended to by pointing to it again


Did you find Ben's post condescending?
[ May 22, 2006: Message edited by: Bear Bibeault ]
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18570
    
    8

Everybody knows there is an API, everybody knows that they could look at it...
Actually, no. I have been answering Java questions here and elsewhere for quite a while and it's fairly obvious to me that there is a certain set of beginners who have no idea that there is a comprehensive set of documentation for the language. I have seen threads where people answer "Look at the documentation here" (with a link) and the response comes back "Thanks, I never knew that was there!"

And there are people who have no idea how to search the Internet. (Yes, choosing the right search keywords is a skill that not everybody has, especially people who don't speak English well and have to search for documents in English.) And there are people who want to write e-mail programs but have not the slightest idea of how e-mail over the Internet actually works. The list goes on; in all fields there are absolute beginners who don't even realize what they don't know.
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

I've worked with plenty of platforms that don't have a documentation scheme that is as consistent and thorough as Java's Javadoc API.
I know that a lot of people come here not knowing about (or fully appreciating the value of) javadocs. The same goes for the Servlet and JSP specs. Because of this, I make a point not to repeat what's in them. I feel it's much more helpful to show newer Java developers, and maybe remind not so new Java developers, that they're there.

We've also compiled a lot of answers to the most commonly asked questions here into a FAQ. If I know the answer is in that FAQ, I'll make a point of linking to that instead of repeating what's already been written.

Personally, I don't think that was a bad question.
I also think that trying to point the original poster in the right direction by giving him a link to the documentation for the object in question is much more helpful than just ignoring him.

If you don't feel the same way, feel free to ignore as many threads as you like.
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

I must admit that I often say that the answer is written in the spec, or api.
Why ? Because I actually search for the answer myself, and what do I do first ? Check the specs ans the api.
And if the answer is there, no need to explain further, "It's written there".
I'm certainly not ignoring the poster's question, because I make sure that the answer is clearly written.
If the poster has already checked the same doc but still does not understand, I'll try to explain.

It's important to know that most of our problems can be solved by checking specs or apis.
It's also important to tell people to check them out, when they don't know that there are such valuable information.


[My Blog]
All roads lead to JavaRanch
narender kaasam
Greenhorn

Joined: May 15, 2006
Posts: 28
Hello guys ,I didn't get answers exactly
Adeel Ansari
Ranch Hand

Joined: Aug 15, 2004
Posts: 2874
- session.invalidate()
- specify the timeout in the web.xml
- session.setMaxInactiveInterval()
Jeff Pollet
Ranch Hand

Joined: Jul 20, 2005
Posts: 49
Well, I think I stand corrected here, on several points. I appreciate the meta-input. The original poster sort of proved all y'all's point with his second post.

I didn't find Ben to be condescending in particular--I was questioning whether pointing to the docs was condescending as a general practice; but y'all have shown me the light. There are good reasons to do so. Thanks again for explaining it in better detail for me.

Also, as far as RTFM goes--I actually didn't even know what that acronym was until I read from a link in Ben's footer which used it:
How To Ask... But I acknowledge that I don't generally find that tone here.
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Originally posted by Jeff Pollet:

Also, as far as RTFM goes--I actually didn't even know what that acronym was until I read from a link in Ben's footer which used it:
How To Ask... But I acknowledge that I don't generally find that tone here.


We have a more "ranche-like" version here:
http://faq.javaranch.com/view?HowToAskQuestionsOnJavaRanch

Even though the original is a bit more harsh, I still use that link because it is more comprehensive. If you can get past the tone and ego, the paper is actually quite informative; both for the asker and the askee.

Anyway, Jeff...
Welcome to the ranch.
Hope you stick around.
-Ben
 
 
subject: How to invalidate session?