aspose file tools*
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
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "doubts  getRequestDispatcher" Watch "doubts  getRequestDispatcher" New topic
Author

doubts getRequestDispatcher

naresh govindaswmay
Ranch Hand

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

{

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");

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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: doubts getRequestDispatcher