Java Reference
In-Depth Information
In the
counter.jsp
example earlier today, the
counter.dat
file was created in the
same folder where
counter.jsp
is stored. Tomcat doesn't store files in the same
folder as servlets.
Review today's material by taking this three-question quiz.
Questions
1.
If a servlet is run at the same time by five web users, how many times is the
servlet's
init()
method called?
a.
5
b.
1
c.
0-1
2.
If you see a request variable on a JSP page, what class in
javax.servlets.http
is
it referring to?
a.
HttpServletResponse
b.
HttpServletRequest
c.
ServletContext
3.
Which of the JSP elements uses the <%= and %> tags?
a.
Declarations
b.
Expressions
c.
Statements
Answers
1. c.
The
init()
method is called when the web server first loads the servlet. This
might have taken place before all five of these users requested the servlet, so it
could call
init()
one time or not at all.
2. b.
HttpServletRequest
3. b.
The expression inside the tags will be evaluated, and its value will be displayed
on the page at the expression's location.