JavaServer Pages QuizS2C Home « JavaServer Pages Quiz

The questions in this quiz on JavaServer Pages are on the topics covered in the JSP section of the site. The table below lists the lessons, a description of the lesson content and the quiz question number range.

Lesson Summary

Click on a lesson in the table to go to that lesson for a refresher on the topics for that lesson.

JSP Lessons Description Question Range
Lesson 1 - Introduction to JSP 2.1In this lesson we begin our studies of using JavaServer Pages (JSPs).1 - 6
Lesson 2 - JSP LifecycleIn this lesson we make a much deeper inpsection of JSPs by looking at the JSP lifecycle and the mechanics of how a JSP is translated into a full-blown servlet.7 - 13
Lesson 3 - JSP Page AnatomyIn this lesson we look at the anatomy of JSP by investigating the various components that can be used within a JSP page.14 - 20
Lesson 4 - Implicit Objectsthis lesson is all about the implicit objects available for use with JSP.21 - 25
Lesson 5 - JSP DirectivesIn this lesson we will take a much closer look at the page and include directives which along with the taglib directive are the only directives which can be included in a JSP page.26 - 31
Lesson 6 - Our First ServletIn this lesson we look at the different Java-based scripting elements available and how we can use them.32 - 37
Lesson 7 - JavaBean Standard ActionsIn this lesson we look at JSP 2.1 standard actions that relate to JavaBeans and how to use them within our JSP pages.38 - 43
Lesson 8 - Other JSP Standard ActionsIn our second lesson on JSP standard actions we look at the jsp:include, jsp:forward and jsp:param standard actions and how to use them.44 - 48

JavaServer Pages Quiz

The quiz below tests your knowledge of the material learnt in the JSP section of the site.

Question 1 : When using JSPs we have to enclose all our HTML tags within Java Strings?
- When using JSPs there is no need to enclose all our HTML tags within Java Strings.
Question 2 : JSP files do not have to be compiled?
- We do not have to compile our JSP files.
Question 3 : Where do we put JSP files that we don't want directly invoked by name?
- We put JSP files that we don't want directly invoked by name within the <code>WEB-INF</code> directory.
Question 4 : When we make changes to a JSP page we have to redeploy the web application it belongs to?
- When we make changes to a JSP page there is no need to redeploy the web application it belongs to.
Question 5 : JSP files within the WEB-INF directory, that we want to access directly from a browser bar, need what?
- JSP files hidden within the <code>WEB-INF</code> directory require DD entries so we can access them directly from a browser bar.
Question 6 : A JSP is translated into a Servlet by the container?
- JSPs are translated into Servlets by the container.
Question 7 : What is the first stage in the JSP lifecycle?
- The first stage in the JSP lifecycle is when the container attempts to translate the JSP page into a JSP implementation page.
Question 8 : How many JSP lifecycle methods are there?
- There are three JSP lifecycle methods, these being <code>jspInit()</code>, <code>_jspService()</code> and <code>jspDestroy()</code>.
Question 9 : Which of these JSP lifecycle stages comes first?
- The container has to instantiate a JSP Servlet before we initialise it.
Question 10 : How many stages are there in the JSP lifecycle?
- There are seven stages in the JSP lifecycle, these being class translation, compilation, loading, instantiation, initialisation, servicing and destruction.
Question 11 : JSP Servlets get loaded by the container on server statup?
- JSP Servlets are lazily initialised and get loaded by the container when required unless instructed to within the DD using the <code>load-on-startup</code> sub-element of the <code>servlet</code> top-level element.
Question 12 : Each JSP servlet gets one of which of the following objects?
- Each JSP servlet gets a <code>ServletConfig</code> object.
Question 13 : The _jspDestroy() lifecycle method will always run for a servlet?
- If a JSP servlet has failed during the initialisation stage of the lifecycle, then no JSP servlet exists to be destroyed as the resources were not configuered correctly and hence the <code>_jspDestroy()</code> method doesn't get invoked.
Question 14 : A JSP page is made up of template data and/or what ?
- JSP page is made up of template data which includes HTML and XML and/or Syntactic elements.
Question 15 : Template data gets translated prior to compilation?
- Template data gets sent without any translation and just gets wrapped in <code>out.write</code> statements.
Question 16 : How many different types of syntactic element are there?
- There are three different types of syntactic element, these being directive, scripting and action elements.
Question 17 : Syntactic elements get translated prior to compilation?
- Syntactic elements need to be translated prior to compilation and are recognized by the translator via a standard sets of characters that mark the beginning an end of the syntactic element.
Question 18 : What type of scripting element is the following code?

<%= new java.util.Date() %>
- Scripting elements that start with <code><%=</code> are known as expressions.
Question 19 : What are standard and custom actions written in?
- Standard and custom actions are written in XML.
Question 20 : What type of scripting element is the following code?

 <%!
    public String getDate() {
        return java.util.Date();
    }
%>
- Scripting elements that start with <code><%!</code> are known as declarations.
Question 21 : All implicit objects are available in any JSP page?
- The <code>exception</code> implicit object is only available in JSP error pages.
Question 22 : How are implicit objects created?
- Implicit objects get created by boilerplate code that gets generated at translation time within the <code>_jspService()</code> method.
Question 23 : How many implicit objects are there?
- There are nine implicit objects, these being application, config, exception, out, page, pageContext, request, response and session.
Question 24 : Which implicit object requires a page directive for creation?
- The <code>exception</code> implicit object requires the <code>isErrorPage</code> page directive to be present so it gets created at translation time.
Question 25 : Which page directive needs to be included to point to an error page?
- The <code>errorPage</code> page directive needs to be included to point to an error page.
Question 26 : What is the page directive used for?
- The <code>page</code> directive is used to instruct the translator about characteristics of the JSP page it is contained within.
Question 27 : Where do we place a page directive within a JSP page?
- The <code>page</code> directive can be placed anywhere within a JSP page. The exception to this rule is when the JSP page contains either the <code>contentType</code> or <code>pageEncoding</code> attributes. If these attributes are present they must precede any template data and data sent using Java code.
Question 28 : How many page directives are allowed within a JSP page?
- You can have multiple <code>page</code> directives within a JSP page.
Question 29 :How many page directive attributes are there?
- There are 15 <code>page</code> directive attributes.
Question 30 :What type of files can we include in a JSP page using the page directive?
- We can include both HTML and JSP files within a JSP page using the <code>errorPage</code> directive
Question 31 : What are pages included using the page directive commonly referred to as?
- Pages included using the <code>errorPage</code> directive are commonly referred to as fragments.
Question 32 : What type of scripting element would we use for writing blocks of Java code?
- We would use scriplets for writing blocks of Java code.
Question 33 : We can only have one type of Java-based scripting present per JSP page?
- JSP pages can have any number of differnt Java-based scripting types present per JSP page.
Question 34 : Variables defined within a scriplet are only visible and usable within that scriplet?
- Variables defined within a scriplet are visible and usable by other scriplets defined below it.
Question 35 : Which scripting element must not have a semicolon at the end of the Java source statement?
- An expression must not have a semicolon at the end of the Java source statement.
Question 36 : Which of the following start tags applies to declarations?
- The <code><%!</code> start tag applies to declarations
Question 37 : Which of the following scripting elements does not get translated into the _jspService() method?
- Declarations do not get translated into the <code>_jspService()</code> method.
Question 38 : What are standard actions written in?
- Standard actions are written in XML.
Question 39 : Which standard action declares an instance of a JavaBean object?
- The <code>jsp:useBean</code> standard action declares an instance of a JavaBean object.
Question 40 : Which is the default scope for a jsp:useBean standard action?
- The <code>jsp:useBean</code> standard action defaults to <code>page</code> scope.
Question 41 : Which jsp:useBean standard action attribute allows us to specify a reference type so we can use polymorphism?
- The <code>type</code> attribute of the <code>jsp:useBean</code> standard action allows us to specify a reference type so we can use polymorphism.
Question 42 : What happens if a jsp:useBean standard action has a body?
- The body of the <code>jsp:useBean</code> standard action is only executed if a JavaBean doesn't already exist.
Question 43 : If the class attribute of the jsp:useBean standard action is used what must the class not be?
- If the <code>class</code> attribute of the <code>jsp:useBean</code> standard action is used the class must not be abstract.
Question 44 : When does inclusion in a JSP page using the jsp:include standard action occur?
- Inclusion into a JSP page using the <code>jsp:include</code> standard action occurs at request time.
Question 45 : Pages included using the jsp:include standard action cannot be executed conditionally?
- Pages included using the <code>jsp:include</code> standard action can be executed conditionally.
Question 46 : Pages included using the jsp:include standard action don't have to exist until request time?
- Pages included using the <code>jsp:include</code> standard action don't have to exist until request time.
Question 47 : When using the jsp:forward standard action which page has responsibility for outputting data?
- When using the <code>jsp:forward</code> standard action the forwarded page has responsibility for outputting data.
Question 48 : What happens when a parameter is added with the jsp:param standard action and the parameter already exists?
- When a parameter is added with the <code>jsp:param</code> standard action and the parameter already exists the parameter is added to the start of the existing parameter list.
Quiz Progress Bar Please select an answer

What's Next?

The next quiz is on the expression language.

go to home page Homepage go to top of page Top