About Question enthuware.jwpv6.2.1090 :

All the posts and topics that contain only an error report will be moved here after the error is corrected. This is to ensure that when users view a question in ETS Viewer, the "Discuss" button will not indicate the presence of a discussion that adds no value to the question.

Moderators: Site Manager, fjwalraven

Post Reply
Ciprian Mihalache
Posts: 51
Joined: Wed Sep 28, 2011 12:14 pm
Contact:

About Question enthuware.jwpv6.2.1090 :

Post by Ciprian Mihalache »

I believe the statement is incomplete, because it does not specify the url used by the servlet.
Consider the following testing code:

Code: Select all

@WebServlet(urlPatterns = { "/servlet", "/p1/servlet", "/p1/p2/servlet", "/p1/p2/p3/servlet" })
public class TestServlet extends HttpServlet {
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		RequestDispatcher requestDispatcher = req.getRequestDispatcher("../html/copyright.txt");
		if (requestDispatcher != null) {
			requestDispatcher.include(req, resp);
		} else {
			resp.getWriter().println("RequestDispatcher is null");
		}
	}
}
The third answer is correct only in case the servlet is called with an url like "/p1/servlet". In case the url of the servlet is "/servlet", the RequestDispatcher is null and in case the url of the servlet is longer ("/p1/p2/servlet" for instance) the RequestDispatcher is not null, but there is a runtime error : FileNotFoundException at address "/p1/html/copyright.txt"
So, the servlet url must be specified in the question statement in order to keep the third answer valid.

admin
Site Admin
Posts: 10388
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.jwpv6.2.1090 :

Post by admin »

You are right. Option 3 is correct only in some situations and not all. The problem statement has now been changed to "Which of the following code fragments occurring in doGet method could possibly achieve this objective?"

The real exam also uses similar construct for the problem statement when an option is a possible solution in some unspecified situation.

thank you for your feedback!
Paul

Post Reply

Who is online

Users browsing this forum: No registered users and 23 guests