JSP Online Quiz


Advertisements


Following quiz provides Multiple Choice Questions (MCQs) related to JSP Fundamentals. You will have to read all the given answers and click over the correct answer. If you are not sure about the answer then you can check the answer using Show Answer button. You can use Next Quiz button to check new set of questions in the quiz.

Questions and Answers

Q 1 - _jspService() method of HttpJspPage class should not be overridden.

A - True

B - False

Answer : A

Explaination

JSP container creates _jspService() methods so it should not be overridden.

Q 2 - Setting isThreadSafe false can lead to poor performance.

A - True

B - False

Answer : A

Explaination

If you set the isThreadSafe option to false, the JSP engine makes sure that only one thread at a time is executing your JSP.

Q 3 - All jsp pages are required to be mapped and configured in web.xml.

A - True

B - False

Answer : B

Explaination

No, Jsp pages are not required to be mapped/configured in web.xml

Q 4 - Which of the following attribute is used to have uncaught run-time exceptions automatically forwarded to an error processing page?

A - error

B - errorPage

C - exception

D - exceptionPage

Answer : B

Explaination

<%@ page errorPage="error.jsp" %>

It will redirect the browser to the JSP page error.jsp if an uncaught exception is encountered during request processing.

Q 5 - Which of the following method can be used to read binary data stream coming from the client?

A - request.getInputStream()

B - response.getInputStream()

C - request.getInputStreamData()

D - response.getInputStreamData()

Answer : A

Explaination

You call request.getInputStream() method to read binary data stream coming from the client for example, image file uploaded.

Answer : C

Explaination

The autoFlush attribute specifies whether buffered output should be flushed automatically when the buffer is filled, or whether an exception should be raised to indicate buffer overflow.

Answer : C

Explaination

The isScriptingEnabled attribute determines if scripting elements are allowed for use. The default value (true) enables scriptlets, expressions, and declarations. If the attribute's value is set to false, a translation-time error will be raised if the JSP uses any scriptlets, expressions (non-EL), or declarations.

Answer : C

Explaination

The getProperty action is used to retrieve the value of a given property and converts it to a string, and finally inserts it into the output.

Answer : C

Explaination

The <c:forEach > tag exists as a good alternative to embedding a Java for, while, or do-while loop via a scriptlet.


jsp_questions_answers.htm

Advertisements