Java - understanding servlets
Posted
by
Trup
on Stack Overflow
See other posts from Stack Overflow
or by Trup
Published on 2012-08-16T02:06:50Z
Indexed on
2012/09/23
15:37 UTC
Read the original article
Hit count: 206
I am working on a homework project that should implement a board game between 2 clients over an HttpServlet. I have couple of questions:
1) I read that HttpServlets must be stateless, however, for the sake of the game, I have to keep a lot of state(whose turn it is, the state of the board, etc). Do I have to keep this in the clients? Does the HttpServlet indeed have to be stateless, i.e. have no fields that track state?
2) I know that the clients will talk to the servlet via the doGet/doPost methods, but how can the servlet talk to the clients(for example, if player 1 just made a move and sent it to the servlet, the servlet has to tell client 2 what the move was).
Thank you
Also, if you can point me to a useful, simple example of a similar code online, I would be very grateful
© Stack Overflow or respective owner