Servlets
Servlet Basics
Originals of Slides and Source Code for Examples: http://courses.coreservlets.com/Course-Materials/csajsp2.html Customized Java EE Training: http://courses.coreservlets.com/
2
Servlets, JSP, JSF 2.0, Struts, Ajax, GWT 2.0, Spring, Hibernate, SOAP & RESTful Web Services, Java 6.
Developed and taught by well-known author and developer. At public venues or onsite at your location.
© 2010 Marty Hall
For live Java EE training, please see training courses at http://courses.coreservlets.com/.
Servlets, JSP, Struts, JSF 1.x, JSF 2.0, Ajax (with jQuery, Dojo,
Prototype, Ext-JS, Google Closure, etc.), GWT 2.0 (with GXT),
Java 5, Java 6, SOAP-based and RESTful Web Services, Spring,
Hibernate/JPA, and customized combinations of topics.
Taught by the author of Core Servlets and JSP, More
Servlets
Servlets and JSP, and this tutorial. Available at public
Available
venues,ustomized Java EE Training: http://courses.coreservlets.com/ at your
C or customized versions can be held on-site
Servlets, JSP, JSF 2.0, Struts, Ajax, GWT 2.0, Spring, Hibernate, SOAP & RESTful Web Services, Java 6. organization. Contact hall@coreservlets.com for details.
Developed and taught by well-known author and developer. At public venues or onsite at your location.
Agenda
•
•
•
•
•
•
•
The basic structure of servlets
A simple servlet that generates plain text
A servlet that generates HTML
Servlets and packages
Some utilities that help build HTML
The servlet life cycle
Servlet debugging strategies
4
A Servlet’s Job
• Read explicit data sent by client (form data)
• Read implicit data sent by client
(request headers)
• Generate the results th • Send the explicit data back to client (HTML)
• Send the implicit data to client th (status codes and response headers)
5
A Servlet That Generates Plain
Text (HelloWorld
Text (HelloWorld.java) import java.io.*; import javax import javax.servlet.*;
import