Servlet - Basic

Print the objectives

Take the exam   Take a beta test

This exam is based on the ability to use the servlet API for basic tasks. This knowledge is still needed when using a web framework (as Struts, Tapestry, Spring MVC, etc.). This exam is complementary to the JSP Basic and the Struts Basic exams. It requires much less knowledge than the SCWCD certification.

Are not part of the basic exam (but kept for intermed & advanced exams):

  • Session attribute listeners
  • Servlet Init params
  • Servlet Context Listeners
  • Work with cookies API.
  • Filters
  • Request wrapper
  • Error handling
  • Security
  Released  Beta  Frozen  

Servlet  1 question

Write a simple Servlet class
  • that correctly extends the HttpServlet class
  • that correctly overrides the appropriate ancestor method
Describe why your servlet must be stateless
  • Explain that the servlet model is multithreaded (1 thread/request)
  • Develop threadsafe servlets by writing stateless servlets (without declared instance variables)
Not Covered : Servlet Lifecycle init(), init(config), ...
13 397 52

Request  3 questions

Differentiate GET and POST HTTP methods
  • Explain how parameters are stored in the request : in the URL or in the body of the HTTP request
  • Identify what default HTTP method will be used when clicking on a link, submitting a form
  • Know that HTML Forms can use both GET and POST
  • Know that the HttpServlet.doGet() & doPost() are called accordingly.

Manipulate request Parameters
  • Write code that retrieves parameters from the HttpServletRequest
  • Identify when getParameter() will return null instead of a valid String
  • Write code that handles multi-valued parameters and retrieves all the values that they contain.
  • Know the correct syntax to pass parameters through a request added to the URL
Not covered: Questions regarding attributes should be placed in the "Attributes" category.
29 78 109

Response  1 question

Produce the HTTP response body
  • Obtain a PrintWriter from the HttpServletResponse object
  • Set the content type of the HttpServletResponse and know that it must be set before the content.
12 41 49

Attributes  2 questions

Retrieve and Store attributes in each scope : HttpServletRequest, HttpSession, ServletContext
  • Explain that null will be returned by the getAttribute() if no attribute can be found
  • Write code that iterates through all the attributes of a given scope
  • Remove attributes from a given scope
Not covered: Related listeners
19 3 49

Session  2 questions

Understand JSESSIONID mechanism

  • Describe the mechanisms that let the web container bind an incoming request to an existing session
    • cookies
    • URL rewriting
    • hidden field
  • Write code that concatenate the JSESSIONID to a URL using the HttpServletResponse.encodeURL() method.
Get the session and manipulate it
  • Write code that retrieves an HttpSession object either by using the getSession() method or by creating a new one if needed using the getSession(boolean) method

Not covered: Related listeners are not part of this exam, questions regarding attributes should be placed in the "Attributes" objectives.

33 89 65

Servlet Context  1 question

Understand the servlet context scope within a web application
  • Identify the ServletContext instance is unique within a web application
  • Write servlet code that gets a reference to the ServletContext object
Not Covered: Questions regarding attributes should be placed in the "Attributes" objectives.
12 23 32

Structure and Deployment  3 questions

Write a simple Deployment Descriptor

  • Configure the web.xml correctly for a basic servlet
    • Write a correct <servlet> element ...
    • ... and the corresponding <servlet-mapping> element
    • Write correct <load-on-startup> element.
Describe a correct directory structure for a WAR file
  • Explain the web.xml must be placed in the WEB-INF directory
  • .class files in the classes directory
  • .jar files in the lib directory
  • Static html files can be placed anywhere except inside the WEB-INF directory
  • Identify which directories are accessible or not to incoming HTTP request URLs

Not covered: no questions on context listener nor init parameters

42 32 94

Exam information

  • 17 minutes
  • 13 questions (1273)
  • 80% required
  • +3 √
  • - 4  points
  • 15 day delay
  • status: released

Top contributors