Forums Register Login

Mock Exam Doubts

+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
Welcome to the ranch ! Please don't forget to quote your sources when you have a question concerning a mock exam.
+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
Hany please QuoteYourSources for the question. We don't allow mock questions on javaranch which don't have proper sources quoted...
+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
Sorry for not posting the source of this mock question earlier, but you can find it in Mock exam
She's out of the country right now, toppling an unauthorized dictatorship. Please leave a message with this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 1167 times.
Similar Threads
Regarding Security Constraint
Webapp Security
mock exam doubts on: security-constraint
SCWCD question
related to auth constraint
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 06:52:32.