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 2 - If a jsp is to generate a pdf page, what attribute of page directive it should use?

A - contentType

B - generatePdf

C - typePDF

B - contentPDF

Answer : A

Explaination

<%page contentType="application/pdf">

Above tag is used to generate PDF using JSP.

Q 3 - Which of the following attributes are mandatory in <jsp:setProperty /> tag?

A - name, property

B - type, id

C - name, type

D - id, property

Answer : A

Explaination

The setProperty action sets the properties of a Bean. The Bean must have been previously defined before this action.

Answer : A

Explaination

The out implicit object is an instance of a javax.servlet.jsp.JspWriter object and is used to send content in a response.

Answer : A

Explaination

When buffer is set to "none", servlet output is immediately directed to the response output object.

Answer : C

Explaination

The include directive is used to includes a file during the translation phase. This directive tells the container to merge the content of other external files with the current JSP during the translation phase.

Answer : C

Explaination

The destruction phase of the JSP life cycle represents when a JSP is being removed from use by a container.The jspDestroy() method is the JSP equivalent of the destroy method for servlets.

Q 9 - Can you make use of a ServletOutputStream object from within a JSP page?

A - true

B - false

Answer : B

Explaination

No. You are supposed to make use of only a JSPWriter object (given to you in the form of the implicit object out) for replying to clients.

Answer : A

Explaination

JavaBeans and taglib fundamentals were introduced for reusability. But following are the major differences between them −

  • Taglibs are for generating presentation elements while JavaBeans are good for storing information and state.

  • Use custom tags to implement actions and JavaBeans to present information.


jsp_questions_answers.htm

Advertisements