Tuesday, April 23, 2013

Java Servlets vs. ASP.NET Applications

When comparing System.Web.HTTPApplication to the Java Servlet, it would appear that the former has advantages in terms of thread safety. Not sure if this comes with a corresponding performance disadvantage...

For instance K. Scott Allen says "one request at a time is associated with an HttpApplication object" and gives an example of an instance member being set to.

By contrast JavaWorld gives an example of how setting instance members is definitely not thread safe, with the only way out being using the now-deprecated SingleThreadInterface (does ASP.NET use a similar mechanism implicitely?) or not using instance methods at all (or using workarounds like synchronization).