| < Free Open Study > |
|
We started this chapter by looking at how Java programs, including web applications are built at run time from classes loaded into memory by classloaders. We saw how classloaders look for classes in locations in a predictable order. The order of precedence determines whether separate web applications each see their own versions of those classes, or whether the classes they use are shared. To help in our investigation we created a servlet, ResourceLocatorServlet, that we used to determine the location from which any given class (or any other resource) will be loaded within Tomcat.
We saw how the container's default model for servlets (multi-threading) can be overridden by implementing the SingleThreadModel interface. Although this guarantees that requests to a particular servlet are serialized it can result in some unwanted side effects. Tomcat actually discourages the use of the SingleThreadModel by not supporting servlet pooling. This means that for maximum concurrency, the default multi-threaded model for servlets must be used.
Finally, we saw how multi-threaded servlets can suffer from race conditions that require the developer to explicitly synchronize access to shared resources such as the instance and class variables, and even context and session attributes in order to make the code thread-safe.
In the next chapter we're going to look at the importance of good design within web applications.
A |
---|
Accessibility
application logic
|
B |
---|
banking application
|
C |
---|
CATALINA_HOME directories
class deployment
class loading, 1
classes
containers
context attributes
|
D |
---|
debugging
deployment
doGet() method
doPost() method
|
E |
---|
explicit synchronization, 20 |
G |
---|
getResource() method
|
H |
---|
HttpServlet class, javax.servlet.http
|
I |
---|
in() method, InOut class
init() method
interfaces
|
J |
---|
JAR (Java application ARchive)
javax.servlet.SingleThreadModel interface
JPDA debugger
|
L |
---|
loading servlets, 11 login() method
|
M |
---|
methods
Microsoft Web Application Stress
multi threaded servlets, 18
|
O |
---|
out() method
|
P |
---|
pooling
|
R |
---|
race condition
reloading servlets, 11 resetValues() method
reusability
|
S |
---|
separation
service() method
servlet 2.3 specification
servlet container
servlets
session attributes
showData() method
single threaded servlets
SingleThreadModel interface
static variables
synchronization, 11
|
T |
---|
testing
threading, 11 Tomcat
transfer() method
|
U |
---|
user tracking application
|
W |
---|
WAR (Web Application ARchive)
Web Application Archive see WAR. web applications
WEB_INF directories
|
| < Free Open Study > |
|