Nearby lessons
22 of 30JSP - MCQ Quiz (Question Bank)
- 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:
- JSP page is translated
- JSP page is compiled
- JSP page implementation class is loaded
- jspInit is called
- _jspService is called
- 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:
| Action | Purpose | Key Attributes |
|---|---|---|
jsp:useBean | Instantiate or locate a JavaBean | id, scope, type, class |
jsp:getProperty | Get a bean property value | name, property |
jsp:setProperty | Set a bean property value | name, property, value, param |
jsp:include | Include another page at runtime | page, flush |
jsp:forward | Forward to another page | page |
jsp:param | Pass parameters to include/forward | name, value |
Key rules:
jsp:useBeanwithclasscreates a new bean; withtypeonly, it must already existjsp:setPropertywithproperty="*"sets all matching request parametersjsp:includeusespageattribute (notfile);jsp:insertdoes not existjsp:parammust be nested insidejsp:include,jsp:forward, orjsp: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.
- 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