Nearby lessons

22 of 30

JSP - MCQ Quiz (Question Bank)

📌 What You Will Learn
  • Test your knowledge across all the JSP units
  • Practise the OCWCD-style question bank
  • Find out which topics need more revision

Test yourself with the complete JSP MCQ quiz — questions from the OCWCD question bank covering the JSP technology model, standard actions, EL, JSTL and custom tags.

Exam Objectives

  • Identify, describe, or write JSP code for: (a) template text, (b) scripting elements (comments, directives, declarations, scriptlets, expressions), (c) standard and custom actions, (d) expression language elements.
  • Write JSP code using the directives: (a) page (with attributes import, session, contentType, isELIgnored), (b) include, (c) taglib.
  • Write a JSP Document (XML-based) with correct syntax.
  • Describe the JSP page lifecycle: translation, compilation, class loading, instantiation, jspInit(), _jspService(), jspDestroy().
  • Write JSP code using implicit objects: request, response, out, session, config, application, page, pageContext, exception.
  • Configure the deployment descriptor to declare tag libraries, deactivate EL, and deactivate scripting.
  • Write JSP code using the most appropriate inclusion mechanism (include directive vs jsp:include).
  • Create code using standard actions: jsp:useBean, jsp:getProperty, jsp:setProperty, jsp:attribute, jsp:include, jsp:forward, jsp:param.
  • Write EL code accessing implicit variables: pageScope, requestScope, sessionScope, applicationScope, param, paramValues, header, headerValues, cookie, initParam, pageContext.
  • Write EL code using operators: property access (.), collection access ([]).
  • Create custom tag libraries and tag files. Describe Classic and Simple tag event models.

Ordering Questions

Q: Place the JSP lifecycle events in order:

  1. JSP page is translated
  2. JSP page is compiled
  3. JSP page implementation class is loaded
  4. jspInit is called
  5. _jspService is called
  6. jspDestroy is called

Q: Place the code to import static content at translation-time:

<%@ include file='foo.jsp' %>

Q: Place the code to access a servlet context attribute as a bean:

<jsp:useBean id='catalog' type='java.util.List' scope='application' />

Q: Place the code to include dynamic content at request-time:

<jsp:include page='foo.jsp' />

Unit 2: Standard Actions Summary

Key standard actions covered in this unit:

ActionPurposeKey Attributes
jsp:useBeanInstantiate or locate a JavaBeanid, scope, type, class
jsp:getPropertyGet a bean property valuename, property
jsp:setPropertySet a bean property valuename, property, value, param
jsp:includeInclude another page at runtimepage, flush
jsp:forwardForward to another pagepage
jsp:paramPass parameters to include/forwardname, value

Key rules:

  • jsp:useBean with class creates a new bean; with type only, it must already exist
  • jsp:setProperty with property="*" sets all matching request parameters
  • jsp:include uses page attribute (not file); jsp:insert does not exist
  • jsp:param must be nested inside jsp:include, jsp:forward, or jsp:plugin

Unit 3: Expression Language Summary

EL implicit objects: pageScope, requestScope, sessionScope, applicationScope, param, paramValues, header, headerValues, cookie, initParam, pageContext.

EL operators: property access (.), collection access ([]), arithmetic (+, -, *, /, %), relational (==, !=, <, >, eq, ne, lt, gt), logical (&&, ||, !, and, or, not), empty.

EL functions: declared in TLD, method must be public static, invoked as ${prefix:functionName(args)}.

Units 4 & 5: JSTL and Custom Tags Summary

JSTL Core: c:out, c:set, c:remove, c:catch, c:if, c:choose/when/otherwise, c:forEach, c:forTokens, c:import, c:redirect, c:url, c:param.

Classic Tags: Tag, IterationTag, BodyTag interfaces; TagSupport, BodyTagSupport classes. Key methods: doStartTag(), doAfterBody(), doEndTag().

Simple Tags: SimpleTag interface; SimpleTagSupport class. Single doTag() method. Objects never reused.

Tag Files: .tag extension in /WEB-INF/tags. No TLD needed. Internally converted to Simple Tag Handlers.

📝 Key Takeaways
  • Questions come from the JSP question bank in the training material
  • Aim to answer each question before revealing the answer
  • Revisit any weak topic from the sidebar

🧠 Test Your Knowledge

108 Questions
Progress: 0 / 108