MCQs > IT & Programming > Java > Suppose you had a servlet that simply returned an error message because that resource was forbidden to that user. Read the following code snippet: 1. public void service(HttpServletRequestrequest, 2. HttpServletResponseresponse) 3. throws ServletException, IOException 4. { 5. 6. } What code would you type on line 5 to return an error message to the requesting client?

Java MCQs

Suppose you had a servlet that simply returned an error message because that resource was forbidden to that user. Read the following code snippet:

1. public void service(HttpServletRequestrequest,
2.           HttpServletResponseresponse)
3. throws ServletException, IOException
4. {
5.
6. }

What code would you type on line 5 to return an error message to the requesting client?



Answer

Correct Answer: response.sendError(HTTPServletResponse.SC_FORBIDDEN,"Error");

Explanation:

Note: This Question is unanswered, help us to find answer for this one

Java Skill Assessment

Overall Skill Level-Poor

Your Skill Level: Poor

Retake Quizzes to improve it

search

Java Skill Assessment

Overall Skill Level-Poor

Your Skill Level: Poor

Retake Quizzes to improve it