I was listening .Net Rocks! podcast (with Scott Hunter) where it was mentioned about session compression. I wonder how can I achieve the session compression in Java?
See Servlet and JSP performance tuning, part 4 for an example of setting the Content-Encoding
HTTP header. Addendum: Checking Accept-Encoding
and handling Content-Encoding
as shown in the article illustrates the the use of the corresponding HTTP headers, but the approach is limited. As BalusC shows, the servlet container itself may support automatic compression, e.g. Tomcat.
The term "session compression" makes no sense in JSP/Servlet. I think you either misunderstood it, or it is just .NET specific. In JSP/Servlet, the session lives actually entirely at the server side. Maybe .NET passes it forth and back to/from the client for some (odd) reason and then compressing the session data would indeed save network bandwidth. But again, this makes no sense in JSP/Servlet. Compressing the session data in server's memory makes also little sense, it would only add more overhead.
To tune your JSP/Servlet webapplication performance I recommend to install YSlow and follow its performance rules. The YSlow's technical tuning advices are however limited to PHP and/or ASP. You can however find details about applying the YSlow performance rules (and much more) in a JSP/Servlet webapplication in this article: Webapplication performance tips and tricks.
Hope this helps.
Well, sessions can be serialized and send across tcp, in the case of clustering.
In that case, the serialization format of the session contents would matter. But that is just straightforward writeObject/readObject coding if optimizations were desired.