| Author |
RequestDispatcher question
|
Tyronne Fernando
Ranch Hand
Joined: May 11, 2008
Posts: 50
|
|
Hi, I got the following question from (http://www.javabeat.net/javabeat/scwcd/mocks/scwcd_1.4_mock_exam_questions_5.php) Following is the code for doGet() method of TestServlet. Which of the given statements about it are correct? public void doGet(HttpServletRequest req, HttpServletResponse res) { try { RequestDispatcher rd = this.getServletContext().getRequestDispatcher("Login.jsp");// 1 rd.forward(req, res); // 2 } catch(Exception e) { e.printStackTrace(); } } Select 2 correct options. A.This will not compile. B.This will compile but will not work as expected. C.This code will work just fine. D.It will compile but not work properly if //1 is replaced with: RequestDispatcher rd = req.getRequestDispatcher("Login.jsp"); E.It will compile and will work properly if //1 is replaced with: RequestDispatcher rd = req.getRequestDispatcher("Login.jsp"); C and E were given as the correct answers. I think B and E are the correct answers, as a RequestDispatcher accessed from the ServletContext should have "/" when the pages are accessed. I like to know some of your thoughts on this. Thanks in advance. Cheers, Tyronne
|
 |
Christian Nicoll
Ranch Hand
Joined: Mar 09, 2008
Posts: 106
|
|
Hi Tyronne, i think you are right und you 've give also the right reasons (missing /) for it.
|
SCJP 5, SCJD 5, SCWCD 5, SCBCD 5, SCJDWS 5
My SCBCD-Notes - My Hello World Webservice
|
 |
 |
|
|
subject: RequestDispatcher question
|
|
|