View RSS Feed

JSP

Is JSP variable declaration thread safe?

Rating: 1 votes, 5.00 average.
by
JSP
, 01-01-2012 at 06:20 PM (2713 Views)
No, in JSP the variable declaration is not at all thread safe as the declared variables are ended up as instance variable in generated servlet not in body of _jspservice() method.

The given declaration is not considered to be thread safe: as they are declarations and are evaluated only one time when page gets loaded.

<%!int a=5;%>

The given declaration is considered thread safe: as in the scriplets the variables that have been declared are not shared and have local scope.

<%int a=5;%>

Submit "Is JSP variable declaration thread safe?" to Facebook Submit "Is JSP variable declaration thread safe?" to Digg Submit "Is JSP variable declaration thread safe?" to del.icio.us Submit "Is JSP variable declaration thread safe?" to StumbleUpon Submit "Is JSP variable declaration thread safe?" to Google

Comments