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");
i think answer are B,E.
But answers are C,E.
is it correct? can you give me some explanation upon it?
I looked at the question and before I saw the answers, I assumed the correct choices were C and E. My reason would be that I don't see any reason why it would on work and would also work if the RequestDispatcher was created from the request object. I know there is a difference between the two ways that affects the path that can be used (I forget this and need to re-read up on it) but I don't think we have any information in the question that would make us think there would be a path problem.
Joined: Mar 26, 2008
Hi Dan, i am sure that "the path string passed to ServeletContext.getRequestDispatcher() must start with '/' " what do you say?
option c is incorrect. This code wont work as such. If we get RequestDispatcher from ServletContext we cannot specify relative path in argument of getRequestDispatcher(). The path should start with forward slash. So options B and E are correct.