Consider the following JSP code (See exhibit).
What will it print for the very first request to this page as well as the web application that contains this page?
Select 1 correct option.
A.It will print Hello!
B.It will print Hello and will set the count attribute in the session.
C.It will throw a NullPointerException at request time.
D.It will not compile.
The answer given is B. I wonder if this is the correct answer because for a very first request req.getSession(false) always returns null.
In the above code else block is executed but it ask for the existing session which is still not available to set the session attribute.
according to me it should print Hello! (option A) please confirm the answer.
Thanks <br />Poonam Agarwal SCWCD 86%
posted 8 years ago
This is jsp file, where you have <%@page session="true" %> by default.