![]() |
JBridge: Certification Question Of The Day |
| JBridge Home >> Certification Questions >> Question for Monday 2nd June 2003 | Monday 2nd June 2003 |
|
What will be the outcome of a user accessing the following uncompiled
JSP for the first time in a fresh browser session? (1 correct
answer) 10 <HTML><HEAD></HEAD><BODY> 11 <P>Session ID: <%-- <%= session.getId() %> --%></P> 12 <%@ page session = "false" %> 13 <% 14 HttpSession session = request.getSession(false); 15 boolean b = (session == null) ? true : false; 16 %> 17 <%= "There is no session: " + b %> 18 </BODY></HTML> A A compilation error will occur because of the misplaced page directive at line 12, which should come before any JSP scriptlets or expressions. B A compilation error will occur because the variable "session" will be declared twice - once as an implicit JSP variable, and again at line 14. C A runtime error will occur, caused by a NullPointerException. D Ouput will be obtained similar to the following: Session ID: There is no session: false E Ouput will be obtained similar to the following: Session ID: There is no session: true F Ouput will be obtained similar to the following: Session ID: 00JPQXYABCD1234888894RTV There is no session: false Page down for the answer... The AnswerThe correct answer is E - the code runs, and produces output as
described. |
EMail: dbridgewater@jbridge.co.uk
Phone: +44 (0)1943 877414
Fax: +44 (0)1943 877414
Mail: David
Bridgewater, Willow Dene, Bradford Road, Menston, Ilkley, West Yorkshire, LS29
6ED, UK
Copyright © 2003 David Bridgewater. All rights reserved.