![]() |
JBridge: Certification Question Of The Day |
| JBridge Home >> Certification Questions >> Question for Tuesday May 27th 2003 | Tuesday May 27th 2003 |
|
Given a request to the servlet code below with URL
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
String s = response.encodeURL(request.getRequestURI());
}
A http://127.0.0.1:8080/WebScratchpad/URLEncoder;jsessionid=9CFE6181885C2CA2BA5A7D2E3C6E4D68
B /WebScratchpad/URLEncoder;JSESSIONID=9CFE6181885C2CA2BA5A7D2E3C6E4D68
C /WebScratchpad/URLEncoder;jsessionid=9CFE6181885C2CA2BA5A7D2E3C6E4D68
D /WebScratchpad/URLEncoder?jsessionid=9CFE6181885C2CA2BA5A7D2E3C6E4D68
E /WebScratchpad/URLEncoder
Page down for the answer... The AnswerThe correct answers are C, D and E.Answer A is not correct because the code retrieves the URI from the request, not the URL (the URL would include the protocol, server and port details; the URI does not include them). Answer B is wrong because there is a rule with session encoding for URLs that the parameter must be jsessionid - sic - in lower case.C is right. The semicolon looks strange, but several servers (including Tomcat) use this "custom" approach. D is also legitimate; jsessionid is encoded as a regular parameter (following the question mark).Finally, E is right - and indeed the most likely. URL encoding won't occur where there is an active session supported by the more usual method of cookies. |
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.