SlideShare a Scribd company logo
1 of 34
Download to read offline
<Insert Picture Here>




Servlets 3.0
Asynchronous, Extensiblity, Ease-of-use
Arun Gupta, Java EE & GlassFish Guy
blogs.sun.com/arungupta, @arungupta
Beijing 2010
December 13–16, 2010




                       2
The following is intended to outline our general
product direction. It is intended for information
purposes only, and may not be incorporated into any
contract. It is not a commitment to deliver any
material, code, or functionality, and should not be
relied upon in making purchasing decisions.
The development, release, and timing of any
features or functionality described for Oracle’s
products remains at the sole discretion of Oracle.




                                                      3
Agenda
• Overview
• Ease of Development
• Dynamic Registration of Servlets and
  Filters
• Pluggability
• Asynchronous Support
• Security Enhancements
• Miscellaneous


                                         4
Overview
l
    Java Servlet 3.0 done as part of JSR 315
    – Final release done in December 2009.
l
    ~20 members in the expert group
    – Major Java EE vendors, open source web container
      developers, framework authors
l
    Main areas of focus
    –   Ease of Development
    –   Pluggability
    –   Asynchronous support
    –   Security


                                                         5
Ease of Development

l
    Enhanced APIs to use new Java SE
    language features introduced since J2SE 5.0
    – Generics for type safety in API where possible
l
    Annotations for declarative style of
    programming
    – web.xml optional
l
    Convention over configuration



                                                       6
Ease of Development
        Use of annotations

l
    Annotations to declare Servlets, Filters,
    Listeners and servlet security
    –   @WebServlet – Define a Servlet
    –   @WebFilter – Define a Filter
    –   @WebListener – Define a Listener
    –   @WebInitParam – Define init param
    –   @MultipartConfig – Define file upload properties
    –   @ServletSecurity – Define security constraints
l
    Can override using “web.xml”


                                                           7
Servlet 2.5 example
   At least 2 files
<!--Deployment descriptor web.xml   /* Code in Java Class */
  -->
<web-app>                           package com.sun;
  <servlet>                         public class MyServlet extends
    <servlet-name>MyServlet         HttpServlet
             </servlet-name>        {
       <servlet-class>                  public void
         com.sun.MyServlet              doGet(HttpServletRequest
       </servlet-class>                 req,HttpServletResponse res)
  </servlet>                            {
  <servlet-mapping>                           ...
    <servlet-name>MyServlet
       </servlet-name>                  }
    <url-pattern>/myApp/*               ...
       </url-pattern>               }
  </servlet-mapping>
   ...
</web-app>



                                                                   8
@WebServlet – Sample Code
@WebServlet(urlPatterns={“/myApp”})
public class SimpleSample extends HttpServlet
{
    public void doGet(HttpServletRequest
           req,HttpServletResponse res)
    {

    }
}




                                                9
@WebServlet Async – Sample Code
@WebServlet(urlPatterns=“/myApp”,
name=”MyServlet”, asyncSupported=true)
public class SimpleSample extends HttpServlet
{
    public void doGet(HttpServletRequest
           req,HttpServletResponse res)
    {

    }
}



                                                10
Dynamic Registration
     Create and/or register
• ServletContext#add[Servlet | Filter]
     • Overloaded versions take [Servlet | Filter] name and
          – Fully qualified [Servlet | Filter] class name or
          – Class <? extends [Servlet | Filter]> or
          – [Servlet | Filter] instance
       • User returned Registration handle to configure all aspects of
         [Servlet | Filter]
l
    ServletContext#create[Servlet | Filter]
    – Takes Class<? Extends [Servlet | Filter]> argument
    – Supports resource injection by container
    – Returned [Servlet | Filter] instance may be fully customized before it
      is registered



                                                                               11
Dynamic Registration
     Lookup
l
    ServletContext#find[Servlet |
    Filter]Registration
    – Takes [Servlet | Filter] name as argument
    – Returned Registration handle provides subset of configuration
      methods
    – May only be used to add initialization parameters and mappings
    – Conflict returned as java.util.Set




                                                                       12
Dynamic Registration
 Register example

ServletRegistration.Dynamic dynamic =
    servletContext.addServlet(
        "DynamicServlet",
        "com.mycom.MyServlet");
dynamic.addMapping("/dynamicServlet");
dynamic.setAsyncSupported(true);




                                         13
Dynamic Registration
   Lookup example

ServletRegistration declared =

servletContext.getServletRegistration("Declare
dServlet");
declared.addMapping("/declaredServlet");
declared.setInitParameter("param", "value");




                                                 14
Pluggability
• Plugin libraries using web fragments
 – Modular web.xml
 – Absolute ordering: <absolute-ordering>
 – Relative ordering: <ordering>, <before>, <after>
• Bundled in framework *.jar/META-INF
• Zero-configuration, drag-and-drop for web
 frameworks
 – Servlets, servlet filters, context listeners for a framework
   get discovered and registered by the container
• Only JAR files in WEB-INF/lib are used


                                                                  15
Pluggability – Sample Code


<web-fragment>
    <filter>
           <filter-name>wicket.helloworld</filter-name>
           <filter-class>org.apache.wicket.protocol.http.WicketFilter</filter-class>
           <init-param>
                 <param-name>applicationClassName</param-name>
                 <param-value>...</param-value>
           </init-param>
    </filter>
    <filter-mapping>
           <filter-name>wicket.helloworld</filter-name>
           <url-pattern>/*</url-pattern>
    </filter-mapping>
</web-fragment>
http://blogs.sun.com/arungupta/entry/totd_91_applying_java_ee



                                                                                16
Pluggability – Sample Code



<web-fragment>
  <filter>
     <filter-name>LiftFilter</filter-name>
      <display-name>Lift Filter</display-name>
      <description>The Filter that intercepts lift calls</description>
      <filter-class>net.liftweb.http.LiftFilter</filter-class>
  </filter>
   <filter-mapping>
     <filter-name>LiftFilter</filter-name>
     <url-pattern>/*</url-pattern>
   </filter-mapping>
</web-fragment>

 http://blogs.sun.com/arungupta/entry/totd_101_applying_servlet_3


                                                                         17
Extensibility
 ServletContainerInitializer

• Container installed JARs
 – App or Library
• Discovered using the service provider API
• Expresses interest in classes via
  @HandlesTypes
• Who uses it ?
 – Mojarra (JSF2) is bootstrapped into GlassFish
    • No “faces-config.xml” or “web.xml”
 – Jersey (JAX-RS) registers root Application
    • No (or portable) “web.xml”

                                                   18
Dynamic Registration
Java Server Faces

    @SuppressWarnings({"UnusedDeclaration"})
    @HandlesTypes({
          ManagedBean.class,
          FacesComponent.class,
          FacesValidator.class,
          FacesConverter.class,
          FacesBehaviorRenderer.class,
          ResourceDependency.class,
          ResourceDependencies.class,
          ListenerFor.class,
          ListenersFor.class,
          UIComponent.class,
          Validator.class,
          Converter.class,
          Renderer.class

    })
    public class FacesInitializer implements ServletContainerInitializer {

        // NOTE: Loggins should not be used with this class.

        private static final String FACES_SERVLET_CLASS =
    FacesServlet.class.getName();




                                                                             19
Dynamic Registration
Java Server Faces

    public void onStartup(Set<Class<?>> classes, ServletContext servletContext)
          throws ServletException {

        if (shouldCheckMappings(classes, servletContext)) {

            Map<String,? extends ServletRegistration> existing =
servletContext.getServletRegistrations();
            for (ServletRegistration registration : existing.values()) {
                if (FACES_SERVLET_CLASS.equals(registration.getClassName())) {
                    // FacesServlet has already been defined, so we're
                    // not going to add additional mappings;
                    return;
                }
            }
            ServletRegistration reg =
                  servletContext.addServlet("FacesServlet",
                                            "javax.faces.webapp.FacesServlet");
            reg.addMapping("/faces/*", "*.jsf", "*.faces");
            servletContext.setAttribute(RIConstants.FACES_INITIALIZER_MAPPINGS_ADDED,
Boolean.TRUE);




                                                                                    20
Resource Sharing
• Static and JSP not confined to document root
  of the web application
• May be placed in WEB-INF/lib/
  [*.jar]/META-INF/resources
• Resources in root take precedence over
  those in bundled JAR
• Container must honor this new location when
 – Processing HTTP requests
 – Calls to ServletContext#getResource[AsStream]


                                                   21
Resource Sharing – Sample Code



myapp.war
  WEB-INF/lib/catalog.jar
             /META-INF/resources/catalog/books.html

http://localhost:8080/myapp/catalog/books.html




                                                      22
Why Asynchronous Servlets?

l
    Not for Async IO
    – Requests mostly small (single packet)
    – Hard to asynchronously produce large responses
    – Async IO support waiting for NIO2

l
    Async Servlets are for:
    – Waiting for resources (eg JDBC connection)
    – Waiting for events (eg Chat)
    – Waiting for responses (eg web services)



                                                       23
Blocking waiting consumes resources

l
    Web Application using remote web services
    – Handling 1000 requests / sec
    – 50% requests call remote web service
    – 500 threads in container thread pool

l
    If remote web service is slow (1000ms)
    – Thread starvation in 1 second!
    – 50% of requests use all 500 threads




                                                24
Asynchronous API
Enable asynchronous support

l
    Configured in
    – web.xml:
      <async-supported>true</async-
      supported>
    – With annotation:
      @WebServlet(asyncSupported=true)
    – Programmatic:
      registration.setAsyncSupported(true)




                                             25
Asynchronous Servlets – Sample Code

   AsyncContext context = request.startAsync();
   context.addListener(new AsyncListener() { … });
   context.dispatch(“/request.jsp”);
   //context.start(Runnable action);
   . . .
   context.complete();




http://blogs.sun.com/arungupta/entry/totd_139_asynchronous_request_processing


                                                                                26
Security
    Annotations to define security constraints
l
    @ServletSecurity used to define access
    control constraints
l
    @HttpConstraint for all HTTP methods
l
    @HttpMethodConstraint for specific HTTP
    methods
l
    More specific wins




                                                 27
Security – Sample Code

@ServletSecurity(
  httpMethodConstraints = {
      @HttpMethodConstraint(value = "GET", rolesAllowed = "R1"),
      @HttpMethodConstraint(value = "POST", rolesAllowed = "R2")
    }
)
public class MyServlet extends HttpServlet {
    // Servlet methods
}




                                                                   28
Security
  Programmatic container authentication and logout

> HttpServletRequest#login(String username,
  String password)
 – Replacement for FBL
 – Application supervises credential collection
> HttpServletRequest#authenticate(HttpServletR
  esponse)
 – Application initiates container mediated authentication from a
   resource that is not covered by any authentication constraints
 – Application decides when authentication must occur




                                                                    29
Miscellaneous Features
l
    Session tracking cookie configuration
    – Via web.xml
    – Programmatic via javax.servlet.SessionCookieConfig
l
    Support for HttpOnly cookie attribute
    – Example:
      servletContext.getSessionCookieConfig().setHttpOnly
      (true)
l
    Default error page
    <error-page>
       <error-code>...</error-code>
       <exception-type>...</exception-type>
       <location>/404.html</location>
    </error-page>



                                                           30
Miscellaneous Features / API (contd)

ServletRequest#getServletContext
ServletRequest#getDispatcherType
Servlet[Request|
Response]Wrapper#isWrapperFor
HttpServletResponse#getStatus
HttpServletResponse#getHeader
HttpServletResponse#getHeaders
HttpServletResponse#getHeaderNames




                                       31
Miscellaneous Features / API (contd)
File upload

ServletRequest#getParts
ServletRequest#getPart
@MultipartConfig
Changes to web.xml




                                       32
Summary
l
    Major revision since Servlet 2.5
l
    Comprehensive set of new features enable
    modern style of web applications and greatly
    increases developer productivity
l
    Simplifies assembly of large applications
    from reusable components




                                               33
References


• glassfish.org
• blogs.sun.com/theaquarium
• youtube.com/user/GlassFishVideos
• facebook.com/glassfish
• Follow @glassfish




                                     34

More Related Content

What's hot

Java EE 6 & GlassFish 3: Light-weight, Extensible, and Powerful @ Silicon Val...
Java EE 6 & GlassFish 3: Light-weight, Extensible, and Powerful @ Silicon Val...Java EE 6 & GlassFish 3: Light-weight, Extensible, and Powerful @ Silicon Val...
Java EE 6 & GlassFish 3: Light-weight, Extensible, and Powerful @ Silicon Val...Arun Gupta
 
Lecture 5 JSTL, custom tags, maven
Lecture 5   JSTL, custom tags, mavenLecture 5   JSTL, custom tags, maven
Lecture 5 JSTL, custom tags, mavenFahad Golra
 
Deep Dive Hands-on in Java EE 6 - Oredev 2010
Deep Dive Hands-on in Java EE 6 - Oredev 2010Deep Dive Hands-on in Java EE 6 - Oredev 2010
Deep Dive Hands-on in Java EE 6 - Oredev 2010Arun Gupta
 
Lecture 3: Servlets - Session Management
Lecture 3:  Servlets - Session ManagementLecture 3:  Servlets - Session Management
Lecture 3: Servlets - Session ManagementFahad Golra
 
GIDS 2012: PaaSing a Java EE Application
GIDS 2012: PaaSing a Java EE ApplicationGIDS 2012: PaaSing a Java EE Application
GIDS 2012: PaaSing a Java EE ApplicationArun Gupta
 
TDC 2011: The Java EE 7 Platform: Developing for the Cloud
TDC 2011: The Java EE 7 Platform: Developing for the CloudTDC 2011: The Java EE 7 Platform: Developing for the Cloud
TDC 2011: The Java EE 7 Platform: Developing for the CloudArun Gupta
 
5050 dev nation
5050 dev nation5050 dev nation
5050 dev nationArun Gupta
 
Arun Gupta: London Java Community: Java EE 6 and GlassFish 3
Arun Gupta: London Java Community: Java EE 6 and GlassFish 3 Arun Gupta: London Java Community: Java EE 6 and GlassFish 3
Arun Gupta: London Java Community: Java EE 6 and GlassFish 3 Skills Matter
 
Spring MVC
Spring MVCSpring MVC
Spring MVCyuvalb
 
GIDS 2012: Java Message Service 2.0
GIDS 2012: Java Message Service 2.0GIDS 2012: Java Message Service 2.0
GIDS 2012: Java Message Service 2.0Arun Gupta
 
JavaServer Faces 2.0 - JavaOne India 2011
JavaServer Faces 2.0 - JavaOne India 2011JavaServer Faces 2.0 - JavaOne India 2011
JavaServer Faces 2.0 - JavaOne India 2011Arun Gupta
 
Multi Client Development with Spring
Multi Client Development with SpringMulti Client Development with Spring
Multi Client Development with SpringJoshua Long
 
Advanced liferay architecture clustering and high availability
Advanced liferay architecture clustering and high availabilityAdvanced liferay architecture clustering and high availability
Advanced liferay architecture clustering and high availabilityBordin Kijsirijareonchai
 
Knowledge Sharing : Java Servlet
Knowledge Sharing : Java ServletKnowledge Sharing : Java Servlet
Knowledge Sharing : Java ServletFahmi Jafar
 

What's hot (20)

Java Servlets & JSP
Java Servlets & JSPJava Servlets & JSP
Java Servlets & JSP
 
Java EE 6 & GlassFish 3: Light-weight, Extensible, and Powerful @ Silicon Val...
Java EE 6 & GlassFish 3: Light-weight, Extensible, and Powerful @ Silicon Val...Java EE 6 & GlassFish 3: Light-weight, Extensible, and Powerful @ Silicon Val...
Java EE 6 & GlassFish 3: Light-weight, Extensible, and Powerful @ Silicon Val...
 
JDBC
JDBCJDBC
JDBC
 
Lecture 5 JSTL, custom tags, maven
Lecture 5   JSTL, custom tags, mavenLecture 5   JSTL, custom tags, maven
Lecture 5 JSTL, custom tags, maven
 
Deep Dive Hands-on in Java EE 6 - Oredev 2010
Deep Dive Hands-on in Java EE 6 - Oredev 2010Deep Dive Hands-on in Java EE 6 - Oredev 2010
Deep Dive Hands-on in Java EE 6 - Oredev 2010
 
Cis 274 intro
Cis 274   introCis 274   intro
Cis 274 intro
 
Lecture 3: Servlets - Session Management
Lecture 3:  Servlets - Session ManagementLecture 3:  Servlets - Session Management
Lecture 3: Servlets - Session Management
 
Os Haase
Os HaaseOs Haase
Os Haase
 
GIDS 2012: PaaSing a Java EE Application
GIDS 2012: PaaSing a Java EE ApplicationGIDS 2012: PaaSing a Java EE Application
GIDS 2012: PaaSing a Java EE Application
 
TDC 2011: The Java EE 7 Platform: Developing for the Cloud
TDC 2011: The Java EE 7 Platform: Developing for the CloudTDC 2011: The Java EE 7 Platform: Developing for the Cloud
TDC 2011: The Java EE 7 Platform: Developing for the Cloud
 
5050 dev nation
5050 dev nation5050 dev nation
5050 dev nation
 
Arun Gupta: London Java Community: Java EE 6 and GlassFish 3
Arun Gupta: London Java Community: Java EE 6 and GlassFish 3 Arun Gupta: London Java Community: Java EE 6 and GlassFish 3
Arun Gupta: London Java Community: Java EE 6 and GlassFish 3
 
Spring MVC
Spring MVCSpring MVC
Spring MVC
 
GIDS 2012: Java Message Service 2.0
GIDS 2012: Java Message Service 2.0GIDS 2012: Java Message Service 2.0
GIDS 2012: Java Message Service 2.0
 
Java server pages
Java server pagesJava server pages
Java server pages
 
JavaServer Faces 2.0 - JavaOne India 2011
JavaServer Faces 2.0 - JavaOne India 2011JavaServer Faces 2.0 - JavaOne India 2011
JavaServer Faces 2.0 - JavaOne India 2011
 
Spring mvc
Spring mvcSpring mvc
Spring mvc
 
Multi Client Development with Spring
Multi Client Development with SpringMulti Client Development with Spring
Multi Client Development with Spring
 
Advanced liferay architecture clustering and high availability
Advanced liferay architecture clustering and high availabilityAdvanced liferay architecture clustering and high availability
Advanced liferay architecture clustering and high availability
 
Knowledge Sharing : Java Servlet
Knowledge Sharing : Java ServletKnowledge Sharing : Java Servlet
Knowledge Sharing : Java Servlet
 

Viewers also liked

To whom it may concern
To whom it may concernTo whom it may concern
To whom it may concernRai Bilal Umar
 
Eligibility certificate
Eligibility certificateEligibility certificate
Eligibility certificateSouvik Maity
 
Job Experience Letter Format
Job Experience Letter FormatJob Experience Letter Format
Job Experience Letter FormatYour HR World
 
To whomsoever it may concern
To whomsoever it may concernTo whomsoever it may concern
To whomsoever it may concernrkrpillai
 
Income tax deduction certificate for tax returns
Income tax deduction certificate for tax returnsIncome tax deduction certificate for tax returns
Income tax deduction certificate for tax returnsmiangee42
 
Internship Certificate
Internship CertificateInternship Certificate
Internship Certificatengoswami
 
Pan card declaration letter format. (1)
Pan card declaration letter format. (1)Pan card declaration letter format. (1)
Pan card declaration letter format. (1)Unnikkrishnan
 
Marwadi stock broking ; priyanka
Marwadi stock broking ; priyankaMarwadi stock broking ; priyanka
Marwadi stock broking ; priyankajitharadharmesh
 
Experience Certificate for YANSAB Saudi Arabia
Experience Certificate for YANSAB Saudi ArabiaExperience Certificate for YANSAB Saudi Arabia
Experience Certificate for YANSAB Saudi ArabiaEalumalai M
 
A project report on dlw export procedure to non railway customer by anand kum...
A project report on dlw export procedure to non railway customer by anand kum...A project report on dlw export procedure to non railway customer by anand kum...
A project report on dlw export procedure to non railway customer by anand kum...Anand Kumar Tiwari
 
Completion Letter Format
Completion Letter FormatCompletion Letter Format
Completion Letter Formatkashyap88
 
TRRAIN: Internship certificate
TRRAIN: Internship certificateTRRAIN: Internship certificate
TRRAIN: Internship certificateNeil Merchant
 
Experience Letter
Experience LetterExperience Letter
Experience LetterAiMSRoyaL
 

Viewers also liked (20)

To whom it may concern
To whom it may concernTo whom it may concern
To whom it may concern
 
Eligibility certificate
Eligibility certificateEligibility certificate
Eligibility certificate
 
Salary Certificate Sample
Salary Certificate SampleSalary Certificate Sample
Salary Certificate Sample
 
Salary certificate
Salary certificateSalary certificate
Salary certificate
 
Job Experience Letter Format
Job Experience Letter FormatJob Experience Letter Format
Job Experience Letter Format
 
To whomsoever it may concern
To whomsoever it may concernTo whomsoever it may concern
To whomsoever it may concern
 
experience certificates.PDF
experience  certificates.PDFexperience  certificates.PDF
experience certificates.PDF
 
To whom it may concern
To whom it may concernTo whom it may concern
To whom it may concern
 
Income tax deduction certificate for tax returns
Income tax deduction certificate for tax returnsIncome tax deduction certificate for tax returns
Income tax deduction certificate for tax returns
 
Internship Certificate
Internship CertificateInternship Certificate
Internship Certificate
 
Experience letter
Experience letterExperience letter
Experience letter
 
TO WHOM IT MAY CONCERN
TO WHOM IT MAY CONCERNTO WHOM IT MAY CONCERN
TO WHOM IT MAY CONCERN
 
Pan card declaration letter format. (1)
Pan card declaration letter format. (1)Pan card declaration letter format. (1)
Pan card declaration letter format. (1)
 
Marwadi stock broking ; priyanka
Marwadi stock broking ; priyankaMarwadi stock broking ; priyanka
Marwadi stock broking ; priyanka
 
Experience Certificate for YANSAB Saudi Arabia
Experience Certificate for YANSAB Saudi ArabiaExperience Certificate for YANSAB Saudi Arabia
Experience Certificate for YANSAB Saudi Arabia
 
A project report on dlw export procedure to non railway customer by anand kum...
A project report on dlw export procedure to non railway customer by anand kum...A project report on dlw export procedure to non railway customer by anand kum...
A project report on dlw export procedure to non railway customer by anand kum...
 
Wipro Experience
Wipro ExperienceWipro Experience
Wipro Experience
 
Completion Letter Format
Completion Letter FormatCompletion Letter Format
Completion Letter Format
 
TRRAIN: Internship certificate
TRRAIN: Internship certificateTRRAIN: Internship certificate
TRRAIN: Internship certificate
 
Experience Letter
Experience LetterExperience Letter
Experience Letter
 

Similar to Servlets 3.0 - Asynchronous, Extensibility, Ease-of-use @ JavaOne Brazil 2010

Servlets 3.0 - Asynchronous, Easy, Extensible @ Silicon Valley Code Camp 2010
Servlets 3.0 - Asynchronous, Easy, Extensible @ Silicon Valley Code Camp 2010Servlets 3.0 - Asynchronous, Easy, Extensible @ Silicon Valley Code Camp 2010
Servlets 3.0 - Asynchronous, Easy, Extensible @ Silicon Valley Code Camp 2010Arun Gupta
 
Boston 2011 OTN Developer Days - Java EE 6
Boston 2011 OTN Developer Days - Java EE 6Boston 2011 OTN Developer Days - Java EE 6
Boston 2011 OTN Developer Days - Java EE 6Arun Gupta
 
Java servlet technology
Java servlet technologyJava servlet technology
Java servlet technologyMinal Maniar
 
Java EE 6 & GlassFish = Less Code + More Power @ DevIgnition
Java EE 6 & GlassFish = Less Code + More Power @ DevIgnitionJava EE 6 & GlassFish = Less Code + More Power @ DevIgnition
Java EE 6 & GlassFish = Less Code + More Power @ DevIgnitionArun Gupta
 
Java EE 6 = Less Code + More Power
Java EE 6 = Less Code + More PowerJava EE 6 = Less Code + More Power
Java EE 6 = Less Code + More PowerArun Gupta
 
ADP - Chapter 2 Exploring the java Servlet Technology
ADP - Chapter 2 Exploring the java Servlet TechnologyADP - Chapter 2 Exploring the java Servlet Technology
ADP - Chapter 2 Exploring the java Servlet TechnologyRiza Nurman
 
UNIT-3 Servlet
UNIT-3 ServletUNIT-3 Servlet
UNIT-3 Servletssbd6985
 
Struts An Open-source Architecture for Web Applications
Struts An Open-source Architecture for Web ApplicationsStruts An Open-source Architecture for Web Applications
Struts An Open-source Architecture for Web Applicationselliando dias
 
JAX-RS 2.0 and OData
JAX-RS 2.0 and ODataJAX-RS 2.0 and OData
JAX-RS 2.0 and ODataAnil Allewar
 
SCWCD : Servlet web applications : CHAP 3
SCWCD : Servlet web applications : CHAP 3SCWCD : Servlet web applications : CHAP 3
SCWCD : Servlet web applications : CHAP 3Ben Abdallah Helmi
 
SCWCD : Servlet web applications : CHAP : 3
SCWCD : Servlet web applications : CHAP : 3SCWCD : Servlet web applications : CHAP : 3
SCWCD : Servlet web applications : CHAP : 3Ben Abdallah Helmi
 
Java Servlets
Java ServletsJava Servlets
Java ServletsNitin Pai
 
Java Spring MVC Framework with AngularJS by Google and HTML5
Java Spring MVC Framework with AngularJS by Google and HTML5Java Spring MVC Framework with AngularJS by Google and HTML5
Java Spring MVC Framework with AngularJS by Google and HTML5Tuna Tore
 
springmvc-150923124312-lva1-app6892
springmvc-150923124312-lva1-app6892springmvc-150923124312-lva1-app6892
springmvc-150923124312-lva1-app6892Tuna Tore
 
Spring into rails
Spring into railsSpring into rails
Spring into railsHiro Asari
 

Similar to Servlets 3.0 - Asynchronous, Extensibility, Ease-of-use @ JavaOne Brazil 2010 (20)

Servlets 3.0 - Asynchronous, Easy, Extensible @ Silicon Valley Code Camp 2010
Servlets 3.0 - Asynchronous, Easy, Extensible @ Silicon Valley Code Camp 2010Servlets 3.0 - Asynchronous, Easy, Extensible @ Silicon Valley Code Camp 2010
Servlets 3.0 - Asynchronous, Easy, Extensible @ Silicon Valley Code Camp 2010
 
Boston 2011 OTN Developer Days - Java EE 6
Boston 2011 OTN Developer Days - Java EE 6Boston 2011 OTN Developer Days - Java EE 6
Boston 2011 OTN Developer Days - Java EE 6
 
Java servlet technology
Java servlet technologyJava servlet technology
Java servlet technology
 
Java EE 6 & GlassFish = Less Code + More Power @ DevIgnition
Java EE 6 & GlassFish = Less Code + More Power @ DevIgnitionJava EE 6 & GlassFish = Less Code + More Power @ DevIgnition
Java EE 6 & GlassFish = Less Code + More Power @ DevIgnition
 
Java EE 6 = Less Code + More Power
Java EE 6 = Less Code + More PowerJava EE 6 = Less Code + More Power
Java EE 6 = Less Code + More Power
 
Servlets
ServletsServlets
Servlets
 
ADP - Chapter 2 Exploring the java Servlet Technology
ADP - Chapter 2 Exploring the java Servlet TechnologyADP - Chapter 2 Exploring the java Servlet Technology
ADP - Chapter 2 Exploring the java Servlet Technology
 
Servlet30 20081218
Servlet30 20081218Servlet30 20081218
Servlet30 20081218
 
UNIT-3 Servlet
UNIT-3 ServletUNIT-3 Servlet
UNIT-3 Servlet
 
Struts An Open-source Architecture for Web Applications
Struts An Open-source Architecture for Web ApplicationsStruts An Open-source Architecture for Web Applications
Struts An Open-source Architecture for Web Applications
 
JAX-RS 2.0 and OData
JAX-RS 2.0 and ODataJAX-RS 2.0 and OData
JAX-RS 2.0 and OData
 
SCWCD : Servlet web applications : CHAP 3
SCWCD : Servlet web applications : CHAP 3SCWCD : Servlet web applications : CHAP 3
SCWCD : Servlet web applications : CHAP 3
 
SCWCD : Servlet web applications : CHAP : 3
SCWCD : Servlet web applications : CHAP : 3SCWCD : Servlet web applications : CHAP : 3
SCWCD : Servlet web applications : CHAP : 3
 
Wt unit 3
Wt unit 3 Wt unit 3
Wt unit 3
 
JAVA Servlets
JAVA ServletsJAVA Servlets
JAVA Servlets
 
Unit 07: Design Patterns and Frameworks (3/3)
Unit 07: Design Patterns and Frameworks (3/3)Unit 07: Design Patterns and Frameworks (3/3)
Unit 07: Design Patterns and Frameworks (3/3)
 
Java Servlets
Java ServletsJava Servlets
Java Servlets
 
Java Spring MVC Framework with AngularJS by Google and HTML5
Java Spring MVC Framework with AngularJS by Google and HTML5Java Spring MVC Framework with AngularJS by Google and HTML5
Java Spring MVC Framework with AngularJS by Google and HTML5
 
springmvc-150923124312-lva1-app6892
springmvc-150923124312-lva1-app6892springmvc-150923124312-lva1-app6892
springmvc-150923124312-lva1-app6892
 
Spring into rails
Spring into railsSpring into rails
Spring into rails
 

More from Arun Gupta

5 Skills To Force Multiply Technical Talents.pdf
5 Skills To Force Multiply Technical Talents.pdf5 Skills To Force Multiply Technical Talents.pdf
5 Skills To Force Multiply Technical Talents.pdfArun Gupta
 
Machine Learning using Kubernetes - AI Conclave 2019
Machine Learning using Kubernetes - AI Conclave 2019Machine Learning using Kubernetes - AI Conclave 2019
Machine Learning using Kubernetes - AI Conclave 2019Arun Gupta
 
Machine Learning using Kubeflow and Kubernetes
Machine Learning using Kubeflow and KubernetesMachine Learning using Kubeflow and Kubernetes
Machine Learning using Kubeflow and KubernetesArun Gupta
 
Secure and Fast microVM for Serverless Computing using Firecracker
Secure and Fast microVM for Serverless Computing using FirecrackerSecure and Fast microVM for Serverless Computing using Firecracker
Secure and Fast microVM for Serverless Computing using FirecrackerArun Gupta
 
Building Java in the Open - j.Day at OSCON 2019
Building Java in the Open - j.Day at OSCON 2019Building Java in the Open - j.Day at OSCON 2019
Building Java in the Open - j.Day at OSCON 2019Arun Gupta
 
Why Amazon Cares about Open Source
Why Amazon Cares about Open SourceWhy Amazon Cares about Open Source
Why Amazon Cares about Open SourceArun Gupta
 
Machine learning using Kubernetes
Machine learning using KubernetesMachine learning using Kubernetes
Machine learning using KubernetesArun Gupta
 
Building Cloud Native Applications
Building Cloud Native ApplicationsBuilding Cloud Native Applications
Building Cloud Native ApplicationsArun Gupta
 
Chaos Engineering with Kubernetes
Chaos Engineering with KubernetesChaos Engineering with Kubernetes
Chaos Engineering with KubernetesArun Gupta
 
How to be a mentor to bring more girls to STEAM
How to be a mentor to bring more girls to STEAMHow to be a mentor to bring more girls to STEAM
How to be a mentor to bring more girls to STEAMArun Gupta
 
Java in a World of Containers - DockerCon 2018
Java in a World of Containers - DockerCon 2018Java in a World of Containers - DockerCon 2018
Java in a World of Containers - DockerCon 2018Arun Gupta
 
The Serverless Tidal Wave - SwampUP 2018 Keynote
The Serverless Tidal Wave - SwampUP 2018 KeynoteThe Serverless Tidal Wave - SwampUP 2018 Keynote
The Serverless Tidal Wave - SwampUP 2018 KeynoteArun Gupta
 
Introduction to Amazon EKS - KubeCon 2018
Introduction to Amazon EKS - KubeCon 2018Introduction to Amazon EKS - KubeCon 2018
Introduction to Amazon EKS - KubeCon 2018Arun Gupta
 
Mastering Kubernetes on AWS - Tel Aviv Summit
Mastering Kubernetes on AWS - Tel Aviv SummitMastering Kubernetes on AWS - Tel Aviv Summit
Mastering Kubernetes on AWS - Tel Aviv SummitArun Gupta
 
Top 10 Technology Trends Changing Developer's Landscape
Top 10 Technology Trends Changing Developer's LandscapeTop 10 Technology Trends Changing Developer's Landscape
Top 10 Technology Trends Changing Developer's LandscapeArun Gupta
 
Container Landscape in 2017
Container Landscape in 2017Container Landscape in 2017
Container Landscape in 2017Arun Gupta
 
Java EE and NoSQL using JBoss EAP 7 and OpenShift
Java EE and NoSQL using JBoss EAP 7 and OpenShiftJava EE and NoSQL using JBoss EAP 7 and OpenShift
Java EE and NoSQL using JBoss EAP 7 and OpenShiftArun Gupta
 
Docker, Kubernetes, and Mesos recipes for Java developers
Docker, Kubernetes, and Mesos recipes for Java developersDocker, Kubernetes, and Mesos recipes for Java developers
Docker, Kubernetes, and Mesos recipes for Java developersArun Gupta
 
Thanks Managers!
Thanks Managers!Thanks Managers!
Thanks Managers!Arun Gupta
 
Migrate your traditional VM-based Clusters to Containers
Migrate your traditional VM-based Clusters to ContainersMigrate your traditional VM-based Clusters to Containers
Migrate your traditional VM-based Clusters to ContainersArun Gupta
 

More from Arun Gupta (20)

5 Skills To Force Multiply Technical Talents.pdf
5 Skills To Force Multiply Technical Talents.pdf5 Skills To Force Multiply Technical Talents.pdf
5 Skills To Force Multiply Technical Talents.pdf
 
Machine Learning using Kubernetes - AI Conclave 2019
Machine Learning using Kubernetes - AI Conclave 2019Machine Learning using Kubernetes - AI Conclave 2019
Machine Learning using Kubernetes - AI Conclave 2019
 
Machine Learning using Kubeflow and Kubernetes
Machine Learning using Kubeflow and KubernetesMachine Learning using Kubeflow and Kubernetes
Machine Learning using Kubeflow and Kubernetes
 
Secure and Fast microVM for Serverless Computing using Firecracker
Secure and Fast microVM for Serverless Computing using FirecrackerSecure and Fast microVM for Serverless Computing using Firecracker
Secure and Fast microVM for Serverless Computing using Firecracker
 
Building Java in the Open - j.Day at OSCON 2019
Building Java in the Open - j.Day at OSCON 2019Building Java in the Open - j.Day at OSCON 2019
Building Java in the Open - j.Day at OSCON 2019
 
Why Amazon Cares about Open Source
Why Amazon Cares about Open SourceWhy Amazon Cares about Open Source
Why Amazon Cares about Open Source
 
Machine learning using Kubernetes
Machine learning using KubernetesMachine learning using Kubernetes
Machine learning using Kubernetes
 
Building Cloud Native Applications
Building Cloud Native ApplicationsBuilding Cloud Native Applications
Building Cloud Native Applications
 
Chaos Engineering with Kubernetes
Chaos Engineering with KubernetesChaos Engineering with Kubernetes
Chaos Engineering with Kubernetes
 
How to be a mentor to bring more girls to STEAM
How to be a mentor to bring more girls to STEAMHow to be a mentor to bring more girls to STEAM
How to be a mentor to bring more girls to STEAM
 
Java in a World of Containers - DockerCon 2018
Java in a World of Containers - DockerCon 2018Java in a World of Containers - DockerCon 2018
Java in a World of Containers - DockerCon 2018
 
The Serverless Tidal Wave - SwampUP 2018 Keynote
The Serverless Tidal Wave - SwampUP 2018 KeynoteThe Serverless Tidal Wave - SwampUP 2018 Keynote
The Serverless Tidal Wave - SwampUP 2018 Keynote
 
Introduction to Amazon EKS - KubeCon 2018
Introduction to Amazon EKS - KubeCon 2018Introduction to Amazon EKS - KubeCon 2018
Introduction to Amazon EKS - KubeCon 2018
 
Mastering Kubernetes on AWS - Tel Aviv Summit
Mastering Kubernetes on AWS - Tel Aviv SummitMastering Kubernetes on AWS - Tel Aviv Summit
Mastering Kubernetes on AWS - Tel Aviv Summit
 
Top 10 Technology Trends Changing Developer's Landscape
Top 10 Technology Trends Changing Developer's LandscapeTop 10 Technology Trends Changing Developer's Landscape
Top 10 Technology Trends Changing Developer's Landscape
 
Container Landscape in 2017
Container Landscape in 2017Container Landscape in 2017
Container Landscape in 2017
 
Java EE and NoSQL using JBoss EAP 7 and OpenShift
Java EE and NoSQL using JBoss EAP 7 and OpenShiftJava EE and NoSQL using JBoss EAP 7 and OpenShift
Java EE and NoSQL using JBoss EAP 7 and OpenShift
 
Docker, Kubernetes, and Mesos recipes for Java developers
Docker, Kubernetes, and Mesos recipes for Java developersDocker, Kubernetes, and Mesos recipes for Java developers
Docker, Kubernetes, and Mesos recipes for Java developers
 
Thanks Managers!
Thanks Managers!Thanks Managers!
Thanks Managers!
 
Migrate your traditional VM-based Clusters to Containers
Migrate your traditional VM-based Clusters to ContainersMigrate your traditional VM-based Clusters to Containers
Migrate your traditional VM-based Clusters to Containers
 

Recently uploaded

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 

Recently uploaded (20)

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 

Servlets 3.0 - Asynchronous, Extensibility, Ease-of-use @ JavaOne Brazil 2010

  • 1. <Insert Picture Here> Servlets 3.0 Asynchronous, Extensiblity, Ease-of-use Arun Gupta, Java EE & GlassFish Guy blogs.sun.com/arungupta, @arungupta
  • 3. The following is intended to outline our general product direction. It is intended for information purposes only, and may not be incorporated into any contract. It is not a commitment to deliver any material, code, or functionality, and should not be relied upon in making purchasing decisions. The development, release, and timing of any features or functionality described for Oracle’s products remains at the sole discretion of Oracle. 3
  • 4. Agenda • Overview • Ease of Development • Dynamic Registration of Servlets and Filters • Pluggability • Asynchronous Support • Security Enhancements • Miscellaneous 4
  • 5. Overview l Java Servlet 3.0 done as part of JSR 315 – Final release done in December 2009. l ~20 members in the expert group – Major Java EE vendors, open source web container developers, framework authors l Main areas of focus – Ease of Development – Pluggability – Asynchronous support – Security 5
  • 6. Ease of Development l Enhanced APIs to use new Java SE language features introduced since J2SE 5.0 – Generics for type safety in API where possible l Annotations for declarative style of programming – web.xml optional l Convention over configuration 6
  • 7. Ease of Development Use of annotations l Annotations to declare Servlets, Filters, Listeners and servlet security – @WebServlet – Define a Servlet – @WebFilter – Define a Filter – @WebListener – Define a Listener – @WebInitParam – Define init param – @MultipartConfig – Define file upload properties – @ServletSecurity – Define security constraints l Can override using “web.xml” 7
  • 8. Servlet 2.5 example At least 2 files <!--Deployment descriptor web.xml /* Code in Java Class */ --> <web-app> package com.sun; <servlet> public class MyServlet extends <servlet-name>MyServlet HttpServlet </servlet-name> { <servlet-class> public void com.sun.MyServlet doGet(HttpServletRequest </servlet-class> req,HttpServletResponse res) </servlet> { <servlet-mapping> ... <servlet-name>MyServlet </servlet-name> } <url-pattern>/myApp/* ... </url-pattern> } </servlet-mapping> ... </web-app> 8
  • 9. @WebServlet – Sample Code @WebServlet(urlPatterns={“/myApp”}) public class SimpleSample extends HttpServlet { public void doGet(HttpServletRequest req,HttpServletResponse res) { } } 9
  • 10. @WebServlet Async – Sample Code @WebServlet(urlPatterns=“/myApp”, name=”MyServlet”, asyncSupported=true) public class SimpleSample extends HttpServlet { public void doGet(HttpServletRequest req,HttpServletResponse res) { } } 10
  • 11. Dynamic Registration Create and/or register • ServletContext#add[Servlet | Filter] • Overloaded versions take [Servlet | Filter] name and – Fully qualified [Servlet | Filter] class name or – Class <? extends [Servlet | Filter]> or – [Servlet | Filter] instance • User returned Registration handle to configure all aspects of [Servlet | Filter] l ServletContext#create[Servlet | Filter] – Takes Class<? Extends [Servlet | Filter]> argument – Supports resource injection by container – Returned [Servlet | Filter] instance may be fully customized before it is registered 11
  • 12. Dynamic Registration Lookup l ServletContext#find[Servlet | Filter]Registration – Takes [Servlet | Filter] name as argument – Returned Registration handle provides subset of configuration methods – May only be used to add initialization parameters and mappings – Conflict returned as java.util.Set 12
  • 13. Dynamic Registration Register example ServletRegistration.Dynamic dynamic = servletContext.addServlet( "DynamicServlet", "com.mycom.MyServlet"); dynamic.addMapping("/dynamicServlet"); dynamic.setAsyncSupported(true); 13
  • 14. Dynamic Registration Lookup example ServletRegistration declared = servletContext.getServletRegistration("Declare dServlet"); declared.addMapping("/declaredServlet"); declared.setInitParameter("param", "value"); 14
  • 15. Pluggability • Plugin libraries using web fragments – Modular web.xml – Absolute ordering: <absolute-ordering> – Relative ordering: <ordering>, <before>, <after> • Bundled in framework *.jar/META-INF • Zero-configuration, drag-and-drop for web frameworks – Servlets, servlet filters, context listeners for a framework get discovered and registered by the container • Only JAR files in WEB-INF/lib are used 15
  • 16. Pluggability – Sample Code <web-fragment> <filter> <filter-name>wicket.helloworld</filter-name> <filter-class>org.apache.wicket.protocol.http.WicketFilter</filter-class> <init-param> <param-name>applicationClassName</param-name> <param-value>...</param-value> </init-param> </filter> <filter-mapping> <filter-name>wicket.helloworld</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> </web-fragment> http://blogs.sun.com/arungupta/entry/totd_91_applying_java_ee 16
  • 17. Pluggability – Sample Code <web-fragment> <filter> <filter-name>LiftFilter</filter-name> <display-name>Lift Filter</display-name> <description>The Filter that intercepts lift calls</description> <filter-class>net.liftweb.http.LiftFilter</filter-class> </filter> <filter-mapping> <filter-name>LiftFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> </web-fragment> http://blogs.sun.com/arungupta/entry/totd_101_applying_servlet_3 17
  • 18. Extensibility ServletContainerInitializer • Container installed JARs – App or Library • Discovered using the service provider API • Expresses interest in classes via @HandlesTypes • Who uses it ? – Mojarra (JSF2) is bootstrapped into GlassFish • No “faces-config.xml” or “web.xml” – Jersey (JAX-RS) registers root Application • No (or portable) “web.xml” 18
  • 19. Dynamic Registration Java Server Faces @SuppressWarnings({"UnusedDeclaration"}) @HandlesTypes({ ManagedBean.class, FacesComponent.class, FacesValidator.class, FacesConverter.class, FacesBehaviorRenderer.class, ResourceDependency.class, ResourceDependencies.class, ListenerFor.class, ListenersFor.class, UIComponent.class, Validator.class, Converter.class, Renderer.class }) public class FacesInitializer implements ServletContainerInitializer { // NOTE: Loggins should not be used with this class. private static final String FACES_SERVLET_CLASS = FacesServlet.class.getName(); 19
  • 20. Dynamic Registration Java Server Faces public void onStartup(Set<Class<?>> classes, ServletContext servletContext) throws ServletException { if (shouldCheckMappings(classes, servletContext)) { Map<String,? extends ServletRegistration> existing = servletContext.getServletRegistrations(); for (ServletRegistration registration : existing.values()) { if (FACES_SERVLET_CLASS.equals(registration.getClassName())) { // FacesServlet has already been defined, so we're // not going to add additional mappings; return; } } ServletRegistration reg = servletContext.addServlet("FacesServlet", "javax.faces.webapp.FacesServlet"); reg.addMapping("/faces/*", "*.jsf", "*.faces"); servletContext.setAttribute(RIConstants.FACES_INITIALIZER_MAPPINGS_ADDED, Boolean.TRUE); 20
  • 21. Resource Sharing • Static and JSP not confined to document root of the web application • May be placed in WEB-INF/lib/ [*.jar]/META-INF/resources • Resources in root take precedence over those in bundled JAR • Container must honor this new location when – Processing HTTP requests – Calls to ServletContext#getResource[AsStream] 21
  • 22. Resource Sharing – Sample Code myapp.war WEB-INF/lib/catalog.jar /META-INF/resources/catalog/books.html http://localhost:8080/myapp/catalog/books.html 22
  • 23. Why Asynchronous Servlets? l Not for Async IO – Requests mostly small (single packet) – Hard to asynchronously produce large responses – Async IO support waiting for NIO2 l Async Servlets are for: – Waiting for resources (eg JDBC connection) – Waiting for events (eg Chat) – Waiting for responses (eg web services) 23
  • 24. Blocking waiting consumes resources l Web Application using remote web services – Handling 1000 requests / sec – 50% requests call remote web service – 500 threads in container thread pool l If remote web service is slow (1000ms) – Thread starvation in 1 second! – 50% of requests use all 500 threads 24
  • 25. Asynchronous API Enable asynchronous support l Configured in – web.xml: <async-supported>true</async- supported> – With annotation: @WebServlet(asyncSupported=true) – Programmatic: registration.setAsyncSupported(true) 25
  • 26. Asynchronous Servlets – Sample Code AsyncContext context = request.startAsync(); context.addListener(new AsyncListener() { … }); context.dispatch(“/request.jsp”); //context.start(Runnable action); . . . context.complete(); http://blogs.sun.com/arungupta/entry/totd_139_asynchronous_request_processing 26
  • 27. Security Annotations to define security constraints l @ServletSecurity used to define access control constraints l @HttpConstraint for all HTTP methods l @HttpMethodConstraint for specific HTTP methods l More specific wins 27
  • 28. Security – Sample Code @ServletSecurity( httpMethodConstraints = { @HttpMethodConstraint(value = "GET", rolesAllowed = "R1"), @HttpMethodConstraint(value = "POST", rolesAllowed = "R2") } ) public class MyServlet extends HttpServlet { // Servlet methods } 28
  • 29. Security Programmatic container authentication and logout > HttpServletRequest#login(String username, String password) – Replacement for FBL – Application supervises credential collection > HttpServletRequest#authenticate(HttpServletR esponse) – Application initiates container mediated authentication from a resource that is not covered by any authentication constraints – Application decides when authentication must occur 29
  • 30. Miscellaneous Features l Session tracking cookie configuration – Via web.xml – Programmatic via javax.servlet.SessionCookieConfig l Support for HttpOnly cookie attribute – Example: servletContext.getSessionCookieConfig().setHttpOnly (true) l Default error page <error-page> <error-code>...</error-code> <exception-type>...</exception-type> <location>/404.html</location> </error-page> 30
  • 31. Miscellaneous Features / API (contd) ServletRequest#getServletContext ServletRequest#getDispatcherType Servlet[Request| Response]Wrapper#isWrapperFor HttpServletResponse#getStatus HttpServletResponse#getHeader HttpServletResponse#getHeaders HttpServletResponse#getHeaderNames 31
  • 32. Miscellaneous Features / API (contd) File upload ServletRequest#getParts ServletRequest#getPart @MultipartConfig Changes to web.xml 32
  • 33. Summary l Major revision since Servlet 2.5 l Comprehensive set of new features enable modern style of web applications and greatly increases developer productivity l Simplifies assembly of large applications from reusable components 33
  • 34. References • glassfish.org • blogs.sun.com/theaquarium • youtube.com/user/GlassFishVideos • facebook.com/glassfish • Follow @glassfish 34