This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes doubts  getRequestDispatcher Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "doubts  getRequestDispatcher" Watch "doubts  getRequestDispatcher" New topic

doubts getRequestDispatcher

naresh govindaswmay
Ranch Hand

Joined: Aug 15, 2007
Posts: 90
7.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)




RequestDispatcher rd = this.getServletContext().getRequestDispatcher("Login.jsp"); // 1

rd.forward(req, res); // 2


catch(Exception e)





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 have selected a and e is the Correct answer. because while using the getservletContext().getRequestDispatcher(); this method will not take the "RELATIVE " path. so that only i made it like that. but they said c and e is teh rite answer. Please Clear this doubt.I am looking for this.

Thanks and Regards<br />Naresh govindaswamy
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
subject: doubts getRequestDispatcher
Similar Threads
RequestDispatcher question
Problem in Mock exam
doubt on RequestDispatcher
Mock exam questions...
SCWCD mock questions II