Wireless Session Tracking
The term session tracking means maintaining state information about a series of requests from the same client. Maintaining such information for clients that use HTTP is a problem. Why? Because HTTP is a request-response protocol, which means the connection between the client and the server is not maintained for the duration of the conversation. In other words, HTTP is a stateless protocol. This means you cannot depend on the underlying connection protocol to maintain state information; you must find other ways to perform session tracking.
The two most widely used techniques for session tracking are
cookies
and
URL rewriting. A cookie is a piece of data that
a Web server sends to the client. This piece of data is stored by the
client and used the next time the client makes a request from that
server. However, if cookies are disabled by the browser or, more
importantly, if the browser itself does not support them (as is the
case with most current wireless devices), then cookies are not of
much use. However, you can send and receive cookies through the use
of the HttpConnection.setRequestProperty( )
and
HttpConnection
.getHeaderField( )
methods. To send a cookie to a server, simply set the
value of the cookie
request property before
sending the message.
String myLocalCookieVariable; HttpConnection connection = (HttpConnection)Connection.open(someURL); Connection.setRequestProperty("cookie", myLocalCookieVariable);
When you receive a response back from the ...
Get Wireless Java now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.