aspose file tools*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Mock Exam Doubts 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 "Mock Exam Doubts" Watch "Mock Exam Doubts" New topic
Author

Mock Exam Doubts

Hany Shafik
Ranch Hand

Joined: Jun 21, 2008
Posts: 80
Hi everyone

I can find the below question recurrent in many mock exams

8. Given:
3: class MyServlet extends HttpServlet {
4: public void doPut(HttpServletRequest req,
HttpServletResponse resp)
throws ServletException, IOException {
5: // servlet code here
...
26: }
27: }
If the DD contains a single security constraint associated with MyServlet and its only <httpmethod>
tags
and <authconstraint>
tags are:
<httpmethod>
GET</httpmethod>
<httpmethod>
PUT</httpmethod>
<authconstraint>
Admin</authconstraint>
Which four requests would be allowed by the container? (Choose four.)
A. A user whose role is Admin can perform a PUT.
B. A user whose role is Admin can perform a GET.
C. A user whose role is Admin can perform a POST.
D. A user whose role is Member can perform a PUT.
E. A user whose role is Member can perform a POST.
F. A user whose role is Member can perform a GET.
Answer: ABCE


I think that the answer is incorrect, because put method is the only http method implemented in MyServlet, All other methods regards of their security constraint will rely with http error 405 "Method is not supported"
So I guess the correct answer would be A only.
I know that the same question above has been posted before, however they were having different concerns than mine.

Please let me know, if my understanding is wrong.
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14688
    
  16

Welcome to the ranch ! Please don't forget to quote your sources when you have a question concerning a mock exam.


[My Blog]
All roads lead to JavaRanch
Lucas Smith
Ranch Hand

Joined: Apr 20, 2009
Posts: 804
    
    1

extends HttpServlet - it means that a couple of methods are inherited. Those methods are in your class. For example - default implementation of doHead(...) invokes doGet(...) method

EDIT
In this case it will not work. doPost and doGet should be implemented.
However it will not work, but because of the lack of implementation, not because authorization.
The answer is rather correct.


SCJP6, SCWCD5, OCE:EJBD6.
BLOG: http://leakfromjavaheap.blogspot.com
Hany Shafik
Ranch Hand

Joined: Jun 21, 2008
Posts: 80
Thanks for reply.
I guess that most of the default implementation of the doXXX methods in HttpServlet returns 405 HTTP error code, I have searched the specs however I couldn't find the part that mandate a default behavior for these methods.
Anyway I guess that the question will be less confusing if they removed the MyServlet class declaration code.
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9313
    
  17

Hany please QuoteYourSources for the question. We don't allow mock questions on javaranch which don't have proper sources quoted...


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
Hany Shafik
Ranch Hand

Joined: Jun 21, 2008
Posts: 80
Hi everyone

I can find the below question recurrent in many mock exams


8. Given:
3: class MyServlet extends HttpServlet {
4: public void doPut(HttpServletRequest req,
HttpServletResponse resp)
throws ServletException, IOException {
5: // servlet code here
...
26: }
27: }
If the DD contains a single security constraint associated with MyServlet and its only <httpmethod>
tags
and <authconstraint>
tags are:
<httpmethod>
GET</httpmethod>
<httpmethod>
PUT</httpmethod>
<authconstraint>
Admin</authconstraint>
Which four requests would be allowed by the container? (Choose four.)
A. A user whose role is Admin can perform a PUT.
B. A user whose role is Admin can perform a GET.
C. A user whose role is Admin can perform a POST.
D. A user whose role is Member can perform a PUT.
E. A user whose role is Member can perform a POST.
F. A user whose role is Member can perform a GET.
Answer: ABCE


I think that the answer is incorrect, because put method is the only http method implemented in MyServlet, All other methods regards of their security constraint will rely with http error 405 "Method is not supported"
So I guess the correct answer would be A only.
I know that the same question above has been posted before, however they were having different concerns than mine.

Please let me know, if my understanding is wrong.
Hany Shafik
Ranch Hand

Joined: Jun 21, 2008
Posts: 80
Sorry for not posting the source of this mock question earlier, but you can find it in Mock exam
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Mock Exam Doubts