Java Servlet 3.0. Rajiv Mordani Spec Lead



Similar documents
Servlet 3.0. Alexis Moussine-Pouchkine. mercredi 13 avril 2011

Piotr Nowicki's Homepage. Java EE 6 SCWCD Mock Exam. "Simplicity is the ultimate sophistication." Important!

SSC - Web applications and development Introduction and Java Servlet (II)

Web Applications. Originals of Slides and Source Code for Examples:

Java Servlet Specification

Java EE 6 Ce qui vous attends

Controlling Web Application Behavior

The Server.xml File. Containers APPENDIX A. The Server Container

Java and Web. WebWork

The Java EE 6 Platform. Alexis Moussine-Pouchkine GlassFish Team

Managing Data on the World Wide-Web

Web Applications. For live Java training, please see training courses at

Java EE Introduction, Content. Component Architecture: Why and How Java EE: Enterprise Java

Introduction to J2EE Web Technologies

Web Container Components Servlet JSP Tag Libraries

Java Web Programming. Student Workbook

GlassFish Security. open source community experience distilled. security measures. Secure your GlassFish installation, Web applications,

Developing Web Applications using JavaServer Pages and Servlets

Principles and Techniques of DBMS 5 Servlet

Java EE 6 New features in practice Part 3

PowerTier Web Development Tools 4

Glassfish, JAVA EE, Servlets, JSP, EJB

CIS 455/555: Internet and Web Systems

Learning GlassFish for Tomcat Users

Java 2 Web Developer Certification Study Guide Natalie Levi

Course Name: Course in JSP Course Code: P5

Tomcat 5 New Features

In this chapter, we lay the foundation for all our further discussions. We start

This presentation will provide a brief introduction to Rational Application Developer V7.5.

Web Application Architecture (based J2EE 1.4 Tutorial)

ACM Crossroads Student Magazine The ACM's First Electronic Publication

What's new in Java EE 6? Antonio Goncalves

Spring 3.1 to 3.2 in a Nutshell. Sam Brannen Senior Software Consultant

Exam Prep. Sun Certified Web Component Developer (SCWCD) for J2EE Platform

JBoss SOAP Web Services User Guide. Version: M5

Server Setup and Configuration

Bienvenue chez le Ch ti JUG!

Creating Java EE Applications and Servlets with IntelliJ IDEA

Supplement IV.E: Tutorial for Tomcat. For Introduction to Java Programming By Y. Daniel Liang

Ch-03 Web Applications

JAX-WS Developer's Guide

Struts 2 - Practical examples

Web Development in Java Live Demonstrations (Live demonstrations done using Eclipse for Java EE 4.3 and WildFly 8)

Oracle Hyperion Financial Management Custom Pages Development Guide

CHAPTER 9: SERVLET AND JSP FILTERS

Servlet and JSP Filters

JWIG Yet Another Framework for Maintainable and Secure Web Applications

CONTROLLING WEB APPLICATION BEHAVIOR WITH

Spring Security SAML module

Web Application Programmer's Guide

OSGi Application Development using GlassFish Server. Version 1.5. By: Sanjeeb Sahoo

Università degli Studi di Napoli Federico II. Corsi di Laurea Specialistica in Ingegneria Informatica ed Ingegneria delle Telecomunicazioni

Integration of Shibboleth and (Web) Applications

Application Security

TIBCO ActiveMatrix BPM Web Application Component Development. Software Release 2.0 November 2012

TIBCO ActiveMatrix Service Grid WebApp Component Development. Software Release August 2012

Web Service Development Using CXF. - Praveen Kumar Jayaram

Nicholas S. Williams. wrox. A Wiley Brand

WEB SERVICES. Revised 9/29/2015

Course Number: IAC-SOFT-WDAD Web Design and Application Development

Programming on the Web(CSC309F) Tutorial: Servlets && Tomcat TA:Wael Aboelsaadat

Running and Testing Java EE Applications in Embedded Mode with JupEEter Framework

Oracle Hyperion Financial Management Developer and Customization Guide

Outline. CS 112 Introduction to Programming. Recap: HTML/CSS/Javascript. Admin. Outline

create-virtual-server creates the named virtual server

Java Servlet Tutorial. Java Servlet Tutorial

An Overview of Servlet & JSP Technology

NetBeans IDE Field Guide

Oracle EXAM - 1Z Java EE 6 Web Services Developer Certified Expert Exam. Buy Full Product.

JSR 289: SIP Servlet 1.1 Provides Significant Benefits for SIP Application Developers

JBoss Portlet Container. User Guide. Release 2.0

Java EE 6 development with Eclipse, Netbeans, IntelliJ and GlassFish. Ludovic Champenois Oracle Corporation

Apache Sling A REST-based Web Application Framework Carsten Ziegeler cziegeler@apache.org ApacheCon NA 2014

Volume 1: Core Technologies Marty Hall Larry Brown. An Overview of Servlet & JSP Technology

ActiveVOS Server Architecture. March 2009

How To Understand The Architecture Of Java 2Ee, J2Ee, And J2E (Java) In A Wordpress Blog Post

Development. with NetBeans 5.0. A Quick Start in Basic Web and Struts Applications. Geertjan Wielenga

Oracle WebLogic Server

Improved Credential and SSL Configuration for EE 7

Complete Java Web Development

Model-View-Controller. and. Struts 2

Oracle WebLogic Foundation of Oracle Fusion Middleware. Lawrence Manickam Toyork Systems Inc

OUR COURSES 19 November All prices are per person in Swedish Krona. Solid Beans AB Kungsgatan Göteborg Sweden

Migrating Applications From IBM WebSphere to Apache Tomcat

Project SailFin: Building and Hosting Your Own Communication Server.

Selected Topics in Java Web Application Development

Web Applications and Struts 2

Server-side OSGi with Apache Sling. Felix Meschberger Day Management AG 124

TIBCO ActiveMatrix BPM WebApp Component Development

Apache. Version 1.0. Developer Guide

Java Server Pages combined with servlets in action. Generals. Java Servlets

CS506 Web Design and Development Solved Online Quiz No. 01

Get Success in Passing Your Certification Exam at first attempt!

MODULAR JAVA WEB APPLICATIONS

Case Studies of Running the Platform. NetBeans UML Servlet JSP GlassFish EJB

Transcription:

Java Servlet 3.0 Rajiv Mordani Spec Lead 1

Overview JCP Java Servlet 3.0 API JSR 315 20 members > Good mix of representation from major Java EE vendors, web container developers and web framework authors 2

Overview Main areas of focus > Ease of Development > Extensibility > Asynchronous support > Security Final release available now as part of Java EE 6 and GlassFish v3 3

Ease of Development Overview Enhance API using new language features in introduced since J2SE 5.0 > Annotations for declarative style of programming > Generics for type safety in API without breaking backwards compatibility Better defaults and convention over configuration 4

Ease of Development Annotations Annotations to declare Servlets, Filters, Listeners and Security constraints > @WebServlet Defines a Servlet > @WebFilter Defines a Filter > @WebListener Defines a listener > @WebInitParam Defines an init param > @ServletSecurity security constraints > @MultipartConfig file upload Use web.xml to override values 5

Ease of Development Use of annotations @WebServlet - For defining a Servlet MUST specify url mapping All other attributes optional with reasonable defaults > For example, the default name of a Servlet is the fully qualified class name Must still extend HttpServlet to derive method contracts for doget, dopost and other methods 6

Ease of Development Servlet 2.5 example /* Code in Java Class */ package com.foo; public class MyServlet extends HttpServlet { public void doget(httpservletrequest req,httpservletresponse res) {... }... } <!--Deployment descriptor web.xml --> <web-app> <servlet> <servlet-name>myservlet </servlet-name> <servlet-class> com.foo.myservlet </servlet-class> </servlet> <servlet-mapping> <servlet-name>myservlet </servlet-name> <url-pattern>/myapp/* </url-pattern> </servlet-mapping>... </web-app> 7

Ease of Development Servlet 3.0 example package com.foo; @WebServlet(name= MyServlet, urlpattern= /myapp/* ) public class MyServlet extends HttpServlet { public void doget(httpservletrequest req, HttpServletResponse res) {... } 8

Extensibility Adding frameworks Enable use of frameworks without boiler plate configuration in deployment descriptors > Put the burden on framework developer Dynamic registration of Servlets and Filters using programmatic configruation APIs Modularize web.xml to allow frameworks to be self-contained Use of annotations enables extensibility as well 9

Dynamic Registration of Servlets and Filters Register Performed during ServletContext initialization ServletContext.add[Servlet Filter] Overloaded versions take [Servlet Filter] name and > Fully qualified class [Servlet Filter] class name > Class<? extends [Servlet Filter]> OR > [Servlet Filter] instance 10

Dynamic Registration of Servlets and Filters Create and Register Use returned Registration handle to configure all aspects of [Servlet Filter] ServletContext.create[Servlet Filter] > Takes Class<? extends [Servlet Filter]> > Container responsible for instantiating [Servlet Filter] > Returned [Servlet Filter] may be customized before it is registered via the ServletContext.add[Servlet Filter] method 11

Dynamic Registration of Servlets and Filters Lookup ServletContext.find[Servlet Filter]Registration > Takes [Servlet Filter] name as argument > Returned Registration handle provides subset of configuration methods > May be used to configure [Servlet Filter] > Conflicts returned as java.util.set 12

Dynamic Registration of Servlets and Filters Register example ServletRegistration.Dynamic dynamic = servletcontext.addservlet( DynamicServle t, com.mycom.myservlet); dynamic.addmapping( /dynamicservlet ); dynamic.setasyncsupported(true); 13

Dynamic Registration of Servlets and Filters Lookup example ServletRegistration declared = servletcontext.getservletregistration( D eclaredservlet ); declared.addmapping( /declaredservlet ); declared.setinitparameter( param, value ); 14

Extensibility web-fragment.xml web-fragment.xml partial web.xml Bundled in framework jar file in META-INF directory Container discovers and assembles the effective descriptor Almost identical to web.xml a few ordering related elements are different Only JAR files in WEB-INF/lib are considered 15

Extensibility web-fragment.xml example <web-fragment> <servlet> <servlet-name>welcome</servlet-name> <servlet-class> WelcomeServlet </servlet-class> </servlet> <servlet-mapping> <servlet-name>welcome</servlet-name> <url-pattern>/welcome</url-pattern> </servlet-mapping>... </web-fragment> 16

Extensibility Ordering Compatible with JavaServer Faces Fragment identified by <name> web.xml may declare absolute ordering of fragments via <absolute-ordering> Fragments may declare ordering preferences relative to other fragments via <ordering> with nested <before> and <after> > Ignored if <absolute-ordering> specified 17

Extensibility ServletContainerInitializer Provided by apps or the container Discovered using the service provider API in the Java runtime Expresses interest in classes via @HandlesTypes Container scans webapp for classes that match @HandlesTypes and passes them to the ServletContainerInitializer, along with ServletContext 18

Extensibility ServletContainerInitializer ServletContainerInitializer inspects passed set of classes and may register Servlets / Filters / Listeners based on them. Mojarra (JSF implementation) plugged into GlassFish v3 using this mechanism 19

Extensibility Resource sharing Static and JavaServer Pages (JSP) resources no longer confined to document root of web application May be placed inside WEB-INF/lib/ [*.jar]/meta-inf/resources Resources in document root take precedence over those in bundled JAR files 20

Asynchronous Support Overview Useful for Comet, long waits Must declare @WebServlet(asyncSupported=true) Then Call AsyncContext ctx = ServletRequest.startAsync(req, res) AsyncContext can then either: dispatch(string path) start(runnable action) Then paired with complete() 21

Asynchronous API ServletRequest ServletRequest.isAsyncSupported() > True if ALL [Filter Servlet]s support async in The Filter chain The Request dispatch chain Can be configured > web.xml > Annotation > API 22

Asynchronous API ServletRequest AsyncContext ServletRequest.startAsync > Called by Servlet Filter > Response not committed on return of service method Filter chain 23

Asynchronous API AsyncContext AsyncContext.dispatch > Called by asynchronous handler > Schedule async dispatch DispatcherType.ASYNC > Response generated by [Servlet Filter] using Container thread pool JSP, JSF or other frameworks 24

Asynchronous API AsyncContext AsyncContext.complete > Called by asynchronous handler or container > Signals Response has been generated 25

Security Programmatic login / logout Support for programmatic authentication, login and logout > HttpServletRequest.authenticate > HttpservletRequest.login > HttpServletRequest.logout Annotations for declaring http constraints for resources > @ServletSecurity 26

Servlet 3.0 Summary Annotations for ease of development Optional web.xml Better defaults Web Framework pluggability Asynchronous Processing Security enhancements 27

Resources Java EE 6 and GlassFish v3 Java EE 6 Home http://java.sun.com/javaee Java EE 6 Downloads http://java.sun.com/javaee/downloads/index.jsp Upcoming Training http://java.sun.com/javaee/support/training/ Sun GlassFish Enterprise Server v3 Home http://www.sun.com/glassfishv3 Community Page glassfish.org White Papers/Webinars http://www.sun.com/glassfish/resources Java EE 6 GlassFish 28

Thank You 29