Please keep all answers short and to the point. Read each question and answer
it; don't add information that wasn't asked for.
(10 points) List two important differences between servlets and CGI scripts. Running a servlet doesn’t require creating a
separate process each time
A servlet stays in memory, so it doesn’t have to be reloaded
each time
One instance handles multiple requests, not
a separate instance for every request
Untrusted servlets can be run
in a “sandbox” Servlets must be in Java; CGI scripts can be in any
language
In an HttpServlet ,
(8 points) What are the names of the two methods you are most
likely to override?
doGet and doPost
(4 points) What are the parameter types required by these two methods?
HttpServletRequest and HttpServletResponse
(12 points) Each servlet has three names. Briefly, what are those names?
The “real” name, given to it by the programmer
An “internal” name,
used only within the web.xml file
The name that the user (client) knows it
by
(5 points) Tomcat requires the Deployment Descriptor file to have a certain
name. What is that name?
web.xml
(12 points) If you don't use Java's Session Tracking API, list the three
techniques you can use to keep track of a session ID.
Hidden <form> fields, cookies, and URL rewriting
(5 points) What session tracking technique does Java's Session Tracking
API use when starting a new session?
It both sends a cookie and does
URL rewriting
(6 points) When using Java's Session Tracking
API, how do you get a session? Specify both the object that you ask
for the session and the message you send to it.
HttpSession session = request.getSession();
(12 points) Tell what goes inside each of the following JSP constructs.
<%= expression %>
<% code, statements %>
<%! declarations %>
(9 points) Name the three scopes that can be accessed by a servlet.
Application scope, Session scope, and Request scope
(4 points) What is the distinction between a parameter and an attribute?
Parameters are read-only
(4 points) In what object does the servlet communicate its results to
the JSP?
In the HttpServletRequest object
(3 points) Name one place that a servlet can keep information that is thread-safe.
Local variables
In the HttpServletRequest object
(or the HttpServletResponse object)
(6 points) In class I listed three advantages of using MVC. Mention two of them.