Hashtable.contains() Tests if some key maps into the specified value in this hashtable.
So, within your Servlet at this line
you’re actually comparing a key (playerid) with all the values (
Player objects) in your Hashtable. Hence, the match is failing every time.
ServletContext (as well as its listener) works fine since you’re receiving your Hashtable (playerList) on every Servlet call correctly. So, to fix the problem use
Hashtable.containsKey() which tests if an object mapping already exists for the specified key.
- Its kind of a misnomer to call a Hashtable a list. Use
playerMapas an identifier since the table maps a
playeridkay to a
- There’s no need to both annotate the listener (with
@WebListener) as well as configure it declaratively in
<listener>). Use only one of the two approaches.
HttpSession.setMaxInactiveInterval()(which sets timeout in secs)
<session-timeout>sets the timeout interval in mins. So, if you wanted a default session length of 3 mins change
solved [Solved] [Solved] [Solved] Servlet context is not working