CHAPTER 8 PERSISTENT COMMUNICATIONS PATTERN 249 public
CHAPTER 8 PERSISTENT COMMUNICATIONS PATTERN 249 public class WhoisOnline extends HttpServlet implements SingleThreadModel { private String _user; private UserIdentificationResolver _userIdentification; private ArrayList _users = new ArrayList(); private int _version; public void init(javax.servlet.ServletConfig config) throws javax.servlet.ServletException { _version = 0; try { _userIdentification = (UserIdentificationResolver)WhoisOnline.class. getClassLoader().loadClass( config.getInitParameter(”user-identification”)).newInstance(); } catch (Exception e) { throw new ServletException( “Could not instantiate _userIdentification”, e); } } protected void service( javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException, java.io.IOException { } protected void doPost(HttpServletRequest request, HttpServletResponse response) throws javax.servlet.ServletException, java.io.IOException { } protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { } } The global resource state for WhoisOnline is the data member _users, which is an array list instance of users who are online. The data member _user represents a transient state used to identify the user currently accessing the resource. The value of _user for the present implementation coincides with the identity of the authenticated user, but as will be illustrated in the following Example: Server Push section, it is not the rule. The data member _userIdentification represents an instance of the user authentication implementation based on the interfaces
Please visit Domain Name Hosting services for high quality webhost to host and run your jsp applications.