Slides © Marty Hall: http://www.moreservlets.com/, book © Sun Microsystems Press
Exam Prep
Sun Certified Web Component Developer
(SCWCD) for J2EE Platform
Core Servlets & JSP book: www.coreservlets.com
More Servlets & JSP book: www.moreservlets.com
Servlet and JSP Training Courses: courses.coreservlets.com
Slides © Marty Hall: http://www.moreservlets.com/, book © Sun Microsystems Press
For full SCWCD preparation, please see JSP
and servlet training course at
http://courses.coreservlets.com/.
Taught by the author of Core Servlets and JSP,
More Servlets and JSP, and this review. Available
at public venues, or customized versions can be
held on-site at your
organization.
Java Web Component Certification4
SCWCD Training: http://courses.coreservlets.com/
Overview
• Must have Java programmer certification first
• Emphasis on memorization
– Names of classes, methods, and packages
– Names of JSP variables and associated classes
– Servlet life cycle
– Custom JSP tag libraries
– web.xml elements
• Official Web Site
– http://suned.sun.com/US/certification/java/
exam_objectives.html
• Format of following slides
– Topic from Sun objectives in black (quoted verbatim)
– Answers and comments in red
– Topics cross referenced to associated sections of
More Servlets and JavaServer Pages (see
http://www.moreservlets.com)
Java Web Component Certification5
SCWCD Training: http://courses.coreservlets.com/
Section 1 – The Servlet Model
• 1.1 For each of the HTTP methods, GET, POST,
and PUT, identify the corresponding method in
the HttpServlet class.
– doGet
– doPost
– doPut
– (doHead, doDelete, doTrace, doOptions)
Details: Section 2.3 of More Servlets and JavaServer Pages
Java Web Component Certification6
SCWCD Training: http://courses.coreservlets.com/
Section 1 – The Servlet Model
• 1.2 For each of the HTTP methods, GET, POST,
and HEAD, identify triggers that might cause a
browser to use the method, and identify
benefits or functionality of the method.
– GET
• Type URL in address line or click on hypertext link
• Submit form with no METHOD or METHOD="GET"
– POST
• Submit form with METHOD="POST"
– HEAD
• I assume question is getting at checking if cached documents are
up to date, but all major browsers use conditional GET requests
(i.e., with If-Modified-Since, not HEAD for this. HEAD returns
HTTP headers but not document.)
Details: Section 2.3 of More Servlets and JavaServer Pages
Java Web Component Certification7
SCWCD Training: http://courses.coreservlets.com/
Section 1 – The Servlet Model
• 1.3 For each of the following operations, identify the
interface and method name that should be used:
– Retrieve HTML form parameters from the request
• request.getParameter (HttpServletRequest)
– Retrieve a servlet initialization parameter
• ServletConfig.getInitParameter
– Retrieve HTTP request header information
• request.getHeader (HttpServletRequest)
– Set an HTTP response header; set the content type of the response
• response.setHeader, response.setContentType
(HttpServletResponse)
– Acquire a stream for the response
• response.getWriter (HttpServletResponse)
– Acquire a binary stream for the response
• response.getOutputStream (HttpServletResponse)
– Redirect an HTTP request to another URL
• res
p
onse.sendRedirect
(
Htt
p
ServletRes
p
onse
)
Java Web Component Certification8
SCWCD Training: http://courses.coreservlets.com/
Section 1 – The Servlet Model
• 1.4 Identify the interface and method to access
values and resources and to set object
attributes within the following three Web
scopes:
– Request
• request.getAttribute, request.setAttribute (HttpServletRequest)
– Session
• session.getAttribute, session.setAttribute (HttpSession)
– Obtain session via request.getSession(true)
– Context
• context.getAttribute, context.setAttribute (ServletContext)
– Obtain context via getServletContext()
Details: Section 3.8 of More Servlets and JavaServer Pages
Java Web Component Certification9
SCWCD Training: http://courses.coreservlets.com/
Section 1 – The Servlet Model
• 1.5 Given a life-cycle method: init, service, or
destroy, identify correct statements about its
purpose or about how and when it is invoked.
– init
• Called when servlet is first loaded (servlet instance created). Not
called for each request.
– service
• Called for each request. Calls doGet, doPost, etc.
– destroy
• Called when the server unloads a servlet (usually because servlet
hasn't been accessed in a long time)
Details: Section 2.3 of More Servlets and JavaServer Pages
Java Web Component Certification10
SCWCD Training: http://courses.coreservlets.com/
Section 1 – The Servlet Model
• 1.6 Use a RequestDispatcher to include or
forward to a Web resource.
– Forwarding (request-based)
SomeClass value = new SomeClass(…);
request.setAttribute("key", value);
String url = "/some-dir/presentation1.jsp";
RequestDispatcher dispatcher =
getServletContext().getRequestDispatcher(url);
dispatcher.forward();
– For including, use include instead of forward and
you can do more processing after the call.
– There is also session-based and context-based sharing
• Don't forget to synchronize for those
– Note: JSP page can be in WEB-INF.
Details: Section 3.8 of More Servlets and JavaServer Pages
Java Web Component Certification11
SCWCD Training: http://courses.coreservlets.com/
Section 2 – The Structure & Deployment
of Modern Servlet Web Applications
• 2.1 Identify the structure of a Web Application
and Web Archive file, the name of the WebApp
deployment descriptor, and the name of the
directories where you place the following:
– The WebApp deployment descriptor
• WEB-INF/web.xml
– The WebApp class files (assumedly they mean unjarred)
• WEB-INF/classes (unpackaged)
• WEB-INF/classes/directoryMatchingPackageName
– Any auxiliary JAR files
• WEB-INF/lib
Details: Chapter 4 of More Servlets and JavaServer Pages
评论0