Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to differ between new request and page refresh..

 
Manoj Amrutkar
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have one chat application for which i am using one simple action class say LoginAction. Now i have index.jsp as the login page. Suppose i want to add the user into chat list when he comes from index.jsp with authentication. Using servletcontext i am managing the list in LoginAction class.
Problem is everytime i refresh a page say with refresh button or pressing f5 same user gets added in to the list.
How can i make a difference between new request and page refresh to avoid so.
If you want i can provide the code also..

Thanks in advance
Manoj Amrutkar
 
Brent Sterling
Ranch Hand
Posts: 948
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am not sure about your "new request versus refresh" question...but the first thing that came to my mind would be to store the list using something like a HashMap, using whatever unique value you have (username?). Then before adding an entry to the list, call the containsKey method and only add new entries.

- Brent
 
Jan Groth
Ranch Hand
Posts: 456
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
... you could use

- the session
- a db-query

to find out that the user is already added to your chat :-)

regards,
jan
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic