Contents • Java Servlets Technology Overview – What is a Java Servlet? – Servlet Services – Why Use Servlets? – Time Servlet – Example – Deploying Servlets on Eclipse IDE 2. Servlets Architecture – Servlets API – Servlets Life-Cycle
Contents 1.Servlet Examples – Processing Parameters – Hello Servlet – Image Counter Servlet 2. Using Sessions–What is a Session? 3. Session Examples – Login / Logout Application – The Browser's Cache Problems
What is a Java Servlet? • Java Servlets are: – Technology for generating dynamic Web pages (like PHP, ASP, ASP.NET, ...) • Protocol and platform-independent server side components, written in Java, which extend the standard Web servers • Java programs that serve HTTP requests • The HttpServlet class – Provides dynamic Web content generation (HTML, XML, …)
What is a Java Servlet? • Servlets – Provide a general framework for services built on the request-response paradigm • Portable to any Java application server • Have access to the entire family of Java and Java EE APIs • JDBC, Persistence, EJB, JMS, JAX-WS,JTA, JTS, RMI, JNDI, JAXP, ... • Fundamental part of all Java Web application technologies (JSP, JSF, ...)
Definition • Java Servlets are programs that run on a Web or Application server and act as a middle layer between a request coming from a Web browser or other HTTP client and databases or applications on the HTTP server. • Using Servlets, you can collect input from users through web page forms, present records from a database or another source, and create web pages dynamically.
Servlets advantages • Performance is significantly better. • It executes within the address space of a Web server. • Platform-independent . • Servlets are trusted -Java security manager on the server enforces a set of restrictions to protect the resources on a server machine • The full functionality of the Java class libraries is available to a servlet. • It can communicate with applets, databases, or other software via the sockets and RMI mechanisms that you have seen already.
Servlet Services • Java Servlets provide many useful services • Provides low-level API for building Internet Services • Serves as foundation to JavaServer Pages (JSP) and JavaServer Faces (JSF) technologies Can deliver multiple types of data to any client • XML, HTML, WML, GIF, etc... • Can serve as “Controller” of JSP/Servlet application
Why Use Servlets? • Safety – Strong type-checking – Memory management • Integration – Servlets tightly coupled with server • Extensibility & Flexibility – Servlets designed to be easily extensible, though currently optimized for HTTP uses – Flexible invocation of servlet (SSI, servlet- chaining,filters, etc.)
Why Use Servlets?
- Fall '19
- World Wide Web, Web server, JavaServer Pages