Amsterdam What is new in Servlet 3.0 ApacheCon 2009.

Slides:



Advertisements
Similar presentations
6 Copyright © 2005, Oracle. All rights reserved. Using Advanced Techniques in Servlets.
Advertisements

Dispatching, monitoring, filtering
Apache Struts Technology
Introducing Apache Tomcat 6 Mladen Turk Red Hat, Inc.
MC365 Application Servers: Servlets. Today We Will Cover: What a servlet is The HTTPServlet and some of its more important methods How to configure the.
An introduction to Java Servlet Programming
Liang, Introduction to Java Programming, Sixth Edition, (c) 2005 Pearson Education, Inc. All rights reserved Chapter 34 Servlets.
Chapter 4 Servlets Concept of Servlets (What, Why, and How) Servlet API Third-party tools to run servlets Examples of Using Servlets HTML tag with GET.
Session-02.
Web Applications Basics. Introduction to Web Web features Clent/Server HTTP HyperText Markup Language URL addresses Web server - a computer program that.
SE-2840 Dr. Mark L. Hornick1 Java Servlet-based web apps Servlet Architecture.
Struts 2.0 an Overview ( )
Introduction to Struts 2.0 Jenny Ni Joey Feng Winddays Wang Hewmmi Zhu Heather Lv Software School,Fudan University 1.
1 Web Technologies in Java EE6 : Servlet 3.0 & JSF 2.0 What's New ? Rohit Kelapure, IBM 11/5/2011.
Servlets Pranav Maydeo. What is a Servlet ? Servlets are modules of Java code that run in a server application to answer client requests. Servlets are.
AN OVERVIEW OF SERVLET TECHNOLOGY SERVER SETUP AND CONFIGURATION WEB APPLICATION STRUCTURE BASIC SERVLET EXAMPLE Java Servlets - Compiled By Nitin Pai.
CSC 2720 Building Web Applications
Chapter 5 Java Servlets. Objectives Explain the nature of a servlet and its operation Use the appropriate servlet methods in a web application Code the.
Basic Struts Architecture Client Server Database Request Response Control View Model Server Struts Framework.
1 ® Copyright 2009 Adobe Systems Incorporated. All rights reserved. Adobe confidential. 1 Building Portlets with ColdFusion Pete Freitag Foundeo, Inc.
® IBM Software Group © 2007 IBM Corporation Servlet Listeners
Java Servlets & Java Server Pages Lecture July 2013.
Java Servlets Lec 27. Creating a Simple Web Application in Tomcat.
Introduction to Apache Tomcat Tim Funk November 2010.
20-Nov-15introServlets.ppt Intro to servlets. 20-Nov-15introServlets.ppt typical web page – source Hello Hello.
@2008 Huynh Ngoc Tin Chapter #2 JAVA SERVLET PRGRAMMING.
® IBM Software Group © 2007 IBM Corporation Servlet Filtering
SE-2840 Dr. Mark L. Hornick1 Servlet Threads and Sessions.
Middleware 3/29/2001 Kang, Seungwoo Lee, Jinwon. Description of Topics 1. CGI, Servlets, JSPs 2. Sessions/Cookies 3. Database Connection(JDBC, Connection.
CSI 3125, Preliminaries, page 1 SERVLET. CSI 3125, Preliminaries, page 2 SERVLET A servlet is a server-side software program, Responds oriented other.
1 Introduction to Servlets. Topics Web Applications and the Java Server. HTTP protocol. Servlets 2.
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3 JSP Application Models.
©SoftMoore ConsultingSlide 1 Filters. Filters can be used in a web application to intercept, examine, and possibly transform requests or responses associated.
CSI 3125, Preliminaries, page 1 SERVLET. CSI 3125, Preliminaries, page 2 SERVLET A servlet is a server-side software program, written in Java code, that.
UMass Lowell Computer Science Java and Distributed Computing Prof. Karen Daniels Fall, 2000 Lecture 21 Java Servlets Wed. 11/22/00 based on material.
Cookies in Servlet A cookie is a small piece of information that is persisted between the multiple client requests. A cookie has a name, a single value,
Chapter 4 Request and Response. Servlets are controlled by the container.
The Chain of Responsibility Pattern (Behavioral) ©SoftMoore ConsultingSlide 1.
1 Lecture 8 George Koutsogiannakis/Summer 2011 CS441 CURRENT TOPICS IN PROGRAMMING LANGUAGES.
Office of Information Technology GT Identity and Access Management JA-SIG CAS project (introducing login.gatech.edu) April 29th,
CS320 Web and Internet Programming Introduction to Java Servlets Chengyu Sun California State University, Los Angeles.
CS-4220 Dr. Mark L. Hornick1 Single class doing too many things =Bad Code Smell.
CS122B: Projects in Databases and Web Applications Spring 2017
Introduction to Servlets
CS3220 Web and Internet Programming Introduction to Java Servlets
CS122B: Projects in Databases and Web Applications Winter 2017
CARA 3.10 Major New Features
Servlet Sessions and Cookies
Servlet Fudamentals.
Java Servlets By: Tejashri Udavant..
JavaServer Pages (JSP)
Java Servlets.
JSON.
Manpower Associates is a $14
Creating Novell Portal Services Gadgets: An Architectural Overview
Pre-assessment Questions
Servlet API and Lifecycle
Chapter 26 Servlets.
Introducing Apache Tomcat 6 Mladen Turk Red Hat, Inc.
CS122B: Projects in Databases and Web Applications Winter 2018
CS122B: Projects in Databases and Web Applications Spring 2018
Servlet APIs Every servlet must implement javax.servlet.Servlet interface Most servlets implement the interface by extending one of these classes javax.servlet.GenericServlet.
Objectives In this lesson you will learn about: Need for servlets
Knowledge Byte In this section, you will learn about:
CS3220 Web and Internet Programming Introduction to Java Servlets
J2EE Lecture 1:Servlet and JSP
Servlets Servlets are modules that extend the functionality of a “java-enabled” web-server They normally generate HTML code and web content dynamically.
Introduction to Java Servlets
Servlets Servlets are modules that extend the functionality of a “java-enabled” web-server They normally generate HTML code and web content dynamically.
CS122B: Projects in Databases and Web Applications Winter 2019
Presentation transcript:

Amsterdam What is new in Servlet 3.0 ApacheCon 2009

Who is Filip Apache Tomcat committer ASF Member Part of the servlet expert group SpringSource Inc employee

Agenda Walk through of features and specification changes in JSR 315 Features, APIs and other information may still change!

Versions Servlet/ JSP Spec Tomcat versionJDK Version xJDK x, 5.5.xJDK xJDK xJDK 1.2+ (?)

Versions Servlet/ JSP Spec Tomcat versionJDK Version ? 7.0.x Java SE 6 (JDK/JRE 1.6) Servlet 3.0 Will Require Java 6

Asynchronous Processing One of the major improvements Most containers already have 'some sort of implementation' Tomcat offers the CometProcessor interface

Asynchronous Processing What is it? Decouple container request thread from ServletRequest/ServletResponse objects

Asynchronous Processing What is it NOT? Non blocking servlet IO implementation – This was briefly discussed – Backwards compatibility challenges – Very complex programming model

Asynchronous Processing What we do today doFilter(Request req, Response res, FilterChain chain) { //pre filter actions chain.doFilter(req,res); //post filter action } service(Request req, Response res) { //read request //write response } Request,Response recycled Request,Response recycled(no filter)

Asynchronous Processing Backwards compatibility? Servlet/Filters are non asynchronous by default – Asynchronous processing requires explicit support in code – Currently done using annotation – Still determining other ways of enabling

Asynchronous Processing Enabling asynchronous public class MyFilter { public class MyServlet { }

Asynchronous Processing Initiating an asynchronous request interface javax.servlet.ServletRequest { AsyncContext startAsync(); AsyncContext startAsync(Request,Response); } throws IllegalStateException if isAsyncSupported() returns false

Asynchronous Processing javax.servlet.AsyncContext Similarities to CometEvent in Tomcat – Wraps request/response objects – Can dispatch the request to a URL – Can request a container thread to execute a task – Can notify container that the request is complete

Asynchronous Processing Asynchronous example service(Request req, Response res) { AsyncContext actx = req.startAsync(); Runnable runnable = new Runnable() { public void run() { Message m = jmsTemplate.receive(); res.write(m); req.complete(); } }; executor.submit(runnable); }

Asynchronous Processing Defensive programming service(Request req, Response res) { if (req.isAsyncSupported()) { AsyncContext actx = req.isAsyncStarted()? req.getAsyncContext(): req.startAsync();... } else {... }

Asynchronous Processing Forwarding to a content generator interface javax.servlet.AsyncContext { void dispatch(); void dispatch(String path); void dispatch(ServletContext ctx, String path) } dispatches to a container thread

Asynchronous Processing Forwarding to a content generator service(Request req, Response res) { final AsyncContext actx = req.startAsync(); Runnable runnable = new Runnable() { public void run() { Message m = jmsTemplate.receive(); req.setAttribute(“quote”,m); actx.dispatch(“/stock/quote.jsp”); } }; executor.submit(runnable); }

Asynchronous Processing Receiving Container Events interface javax.servlet.AsyncListener { void onComplete(AsyncEvent event); void onTimeout(AsyncEvent event); }

Asynchronous Processing That's enough for now! A detailed paper on asynchronous processing – Has been submitted to ApacheCon US 2009 CFP

Web Fragments Ability to submit web.xml fragments with JAR packaged libraries Can be disabled using true

Web Fragments mylib.jar/META-INF/web-fragment.xml MyServlet MyServlet *.tsp

Web Fragments Ordering of web fragments Absolute ordering – web.xml - Relative ordering – web-fragment.xml -

Web Fragments Ordering is name based MyWebFragment1 MyWebFragment2

Pluggability Programatically add - Servlets - Filters To a ServletContext Can only be done during the ServletContext initialization phase – contextInitialized() method of ServletContextListener

Pluggability Adding Servlets & Filters interface javax.servlet.ServletContext { FilterRegistration addFilter( String filterName, String|Class filterClass); ServletRegistration addServlet( String servletName, String|Class servletClass); }

Pluggability Registration objects interface Servlet/Filter-Registration{ setDescription(String); setInitParameter(String name,Object value); setInitParameters(Map p); setAsyncSupported(boolean supported); addMappingForUrlPatterns(...); }

Annotations New annotations added (must extend HttpServlet) (must implement Filter) (both servlets/filters) ServletContextListener (& attr listener) HttpSessionListener (& attr listener) ServletRequestListener (& attr listener)

Security New methods interface HttpServletRequest{ login(HttpServletResponse resp); login(String username, String password); logout(); }

Security Allow a login to happen on a non constrained request Sensitive to the response being committed – In order to set a session cookie, when configured

File Upload Is being considered for addition Challenge: Servlet 3.0 doesn't have non blocking IO – Removes the usefulness of having yet another file upload API Based on javax.activation – That is part of Java SE 6

Session Cookie Configuration Configure the session cookie interface javax.servlet.SessionCookieConfig { setName(String name); setSecure(boolean isSecure); setHttpOnly(boolean isHttpOnly); setPath(String path); setDomain(String domain); setComment(String comment); }

Timeline Originally planned June 2009 May be pushed to September 2009 – JEE spec needs more time

Questions and Answer