Java Reference
In-Depth Information
getId()— Returns a string with a unique identifier representing this session
getPathParameters()— Returns parameters passed in as a part of the URL
getQueryString()— Returns the query string of the URL (?vaca-
tion=yes )
getRequestParameterMap()— Query string parsed and returned in a map
getRequestURI()— URI under which this session was opened
isOpen()— Returns true if the connection is still valid
isSecure()— Returns true if the connection is using secure sockets
getUserPrincipal()— Returns the authenticated user or null if none
getUserProperties()— Returns a Map<String,String> that can be
used to store data
addMessageHandler() —registers a message handler used by programmatic
If the user has logged into the application via realm-based security, the getUserPrin-
cipal() will return the principal object. This is used in the ActionBazaar example in the
next section. The getId() method is useful to identify a specific session; remember that
there may be multiple sessions open to one client ( getOpenSessions() will provide
a list), so don't assume there's one session for a client or attempt to use an IP address to
identify an end user.
Validity of isOpen
With the isOpen() call, remember that isOpen() is only valid the instant it's called.
Just because it returns true doesn't mean the connection is still open and that your next
call to send a message will succeed. The client may be in the process of closing the con-
nection and a split millisecond later it'll actually be closed. isOpen() is useful only if it
returns false . Don't make any assumptions with isOpen() !
In the next section we'll look at decoders and encoders, which you'll need to understand
when processing messages.
Search WWH ::

Custom Search