aspose file tools*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Mock exam questions... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Mock exam questions..." Watch "Mock exam questions..." New topic
Author

Mock exam questions...

Hendy Setyo Mulyo
Ranch Hand

Joined: Dec 01, 2004
Posts: 219

Hi ranchers,

This is taken from the mock exams:

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");
ANS : C,E

My answer should be B, E. Am I wrong?


Hendy Setyo Mulyo
SCJP 1.4 (95%), SCWCD 1.4 (94%)
Manikandan Jayaraman
Ranch Hand

Joined: Sep 15, 2004
Posts: 230
I find your answer to be right! B and E should be the right ones.


Regards,<br />Mani<br />SCJP 1.4 (95%)<br />SCWCD 1.4 (94%)
Hendy Setyo Mulyo
Ranch Hand

Joined: Dec 01, 2004
Posts: 219

Thanks Mani,

But now I have doubt again:

8.Consider the web.xml snippet shown in the exhibit.
Now consider the code for a jsp file named unprotected.jsp:
<html>
<body>
<jsp:include page="/jsp/protected.jsp" />
</body>
</html>
Which of the following statements hold true when unprotected.jsp is requested by an unauthorized user?
<web-app>
...
<security-constraint>
<web-resource-collection>
<web-resource-name>test</web-resource-name>
<url-pattern>/jsp/protected.jsp</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>manager</role-name>
</auth-constraint>
</security-constraint>
...
</web-app>
Select 1 correct option.
A.The user will be prompted to enter user name and password
B.An exception will be thrown
C.protected.jsp will be executed but it's output will not be included in the response
D.The call to include will be ignored
E.None of these
ANS : E

I think the answer should be B, because it is attempting to access unauthorized resource. Can someone explain this?
Thanks a lot.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Mock exam questions...