servlet 3.0: empowering your web applications with async, extensibility and more

54
Java™ Servlet 3.0: Empowering Your Web Applications With Async E!tensibility an" #ore Rajiv Mordani, Jan Luehe Sun Microsystems Greg Wilkins Webtide / Jetty

Upload: nwwar

Post on 04-Jun-2018

215 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Servlet 3.0:   Empowering Your Web   Applications With Async,   Extensibility and More

8/14/2019 Servlet 3.0: Empowering Your Web Applications With Async, Extensibility and More

http://slidepdf.com/reader/full/servlet-30-empowering-your-web-applications-with-async-extensibility-and 1/54

Page 2: Servlet 3.0:   Empowering Your Web   Applications With Async,   Extensibility and More

8/14/2019 Servlet 3.0: Empowering Your Web Applications With Async, Extensibility and More

http://slidepdf.com/reader/full/servlet-30-empowering-your-web-applications-with-async-extensibility-and 2/54

 Agenda

● vervie!

● "ase o# $evelo%ment

$ynamic registration o# Servlets and &ilters● 'luggability

●  Asynchronous su%%ort

Security enhancements● Miscellaneous

Page 3: Servlet 3.0:   Empowering Your Web   Applications With Async,   Extensibility and More

8/14/2019 Servlet 3.0: Empowering Your Web Applications With Async, Extensibility and More

http://slidepdf.com/reader/full/servlet-30-empowering-your-web-applications-with-async-extensibility-and 3/54

3

vervie!● Java Servlet ()* A'+ JSR (-.

●  About * members in the e0%ert grou%

● Good mi0 o# re%resentation #rom major Java ""

vendors, !eb container vendors and individual!eb #rame!ork authors

● Main areas o# #ocus

● "ase o# $evelo%ment

● 'luggability

●  Asynchronous su%%ort

● Security

Page 4: Servlet 3.0:   Empowering Your Web   Applications With Async,   Extensibility and More

8/14/2019 Servlet 3.0: Empowering Your Web Applications With Async, Extensibility and More

http://slidepdf.com/reader/full/servlet-30-empowering-your-web-applications-with-async-extensibility-and 4/54

4

Status

● S%eci#ication in 'ro%osed &inal $ra#t

● &inal release aligned !ith Java "" 1

Page 5: Servlet 3.0:   Empowering Your Web   Applications With Async,   Extensibility and More

8/14/2019 Servlet 3.0: Empowering Your Web Applications With Async, Extensibility and More

http://slidepdf.com/reader/full/servlet-30-empowering-your-web-applications-with-async-extensibility-and 5/54

 Agenda

● vervie!

● "ase o# $evelo%ment

$ynamic registration o# Servlets and &ilters● 'luggability

●  Asynchronous su%%ort

Security enhancements● Miscellaneous

Page 6: Servlet 3.0:   Empowering Your Web   Applications With Async,   Extensibility and More

8/14/2019 Servlet 3.0: Empowering Your Web Applications With Async, Extensibility and More

http://slidepdf.com/reader/full/servlet-30-empowering-your-web-applications-with-async-extensibility-and 6/54

"ase o# $evelo%ment 2"o$3

● &ocus on "ase o# $evelo%ment 2"o$3 in theServlet ()* A'+

● "nhance A'+ to use the ne! language #eaturesintroduced since JS" .)*

●  Annotations #or declarative style o# %rogramming

● 4o !eb)0ml needed

● Generics #or ty%e sa#ety in the A'+ !ithoutbreaking back!ards com%atibility

● 5etter de#aults and convention over con#iguration

Page 7: Servlet 3.0:   Empowering Your Web   Applications With Async,   Extensibility and More

8/14/2019 Servlet 3.0: Empowering Your Web Applications With Async, Extensibility and More

http://slidepdf.com/reader/full/servlet-30-empowering-your-web-applications-with-async-extensibility-and 7/547 

"ase o# $evelo%ment6se o# Annotations●  Annotations to declare Servlets, &ilters, Listeners

and security constraints

● @WebServlet – $e#ine a Servlet

● @WebFilter – $e#ine a &ilter ● @WebListener – $e#ine a Listener 

● @WebInitParam – $e#ine init %arams

● @MultipartConfig – $e#ine #ileu%load%ro%erties

● 7an use !eb)0ml to override values s%eci#ied inthe annotations

Page 8: Servlet 3.0:   Empowering Your Web   Applications With Async,   Extensibility and More

8/14/2019 Servlet 3.0: Empowering Your Web Applications With Async, Extensibility and More

http://slidepdf.com/reader/full/servlet-30-empowering-your-web-applications-with-async-extensibility-and 8/548 

"ase o# $evelo%ment

6se o# Annotations 2contd3● @WebServlet #or de#ining a Servlet

8 9he annotation M6S9 have at a minimum the6RL %attern #or the Servlet

8  All other #ields o%tional !ith reasonable de#aults

8 &or e0am%le, the de#ault name o# the Servlet isthe #ully :uali#ied class name

8

7lass M6S9 still e0tend HttpServlet8 Method contracts #or doGet, doPost 

inherited #rom abstract class

Page 9: Servlet 3.0:   Empowering Your Web   Applications With Async,   Extensibility and More

8/14/2019 Servlet 3.0: Empowering Your Web Applications With Async, Extensibility and More

http://slidepdf.com/reader/full/servlet-30-empowering-your-web-applications-with-async-extensibility-and 9/549

Servlet ). e0am%le

 publi lass SimpleSamplee!tends HttpServlet "

  publi void doGet$HttpServlet%e&uest re&,HttpServlet%esponse res'"

  (

(

!eb)0ml2intentionally le#tunreadable3

 )*eb+app 

  )servlet 

  )servlet+name M-Servlet

  ).servlet+name 

  )servlet+lass

samples/SimpleSample

  ).servlet+lass 

  ).servlet 

  )servlet+mapping 

  )servlet+name

 M-Servlet

  ).servlet+name 

  )url+pattern 

  .M-0pp

  ).url+pattern 

  ).servlet+mapping 

///

 ).*eb+app 

Page 10: Servlet 3.0:   Empowering Your Web   Applications With Async,   Extensibility and More

8/14/2019 Servlet 3.0: Empowering Your Web Applications With Async, Extensibility and More

http://slidepdf.com/reader/full/servlet-30-empowering-your-web-applications-with-async-extensibility-and 10/54

Page 11: Servlet 3.0:   Empowering Your Web   Applications With Async,   Extensibility and More

8/14/2019 Servlet 3.0: Empowering Your Web Applications With Async, Extensibility and More

http://slidepdf.com/reader/full/servlet-30-empowering-your-web-applications-with-async-extensibility-and 11/5411

Servlet ()* e0am%le

@WebServlet$urlPatterns31.foo2,name32M-Servlet2, as-nSupported3true'

 publi lass SimpleSample e!tends

HttpServlet"

  publi void doGet$HttpServlet%e&uestre&,HttpServlet%esponse res'

"

  (

(

Page 12: Servlet 3.0:   Empowering Your Web   Applications With Async,   Extensibility and More

8/14/2019 Servlet 3.0: Empowering Your Web Applications With Async, Extensibility and More

http://slidepdf.com/reader/full/servlet-30-empowering-your-web-applications-with-async-extensibility-and 12/5412 

 Agenda

● vervie!

● "ase o# $evelo%ment

$ynamic registration o# Servlets and &ilters● 'luggability

●  Asynchronous su%%ort

Security enhancements● Miscellaneous

Page 13: Servlet 3.0:   Empowering Your Web   Applications With Async,   Extensibility and More

8/14/2019 Servlet 3.0: Empowering Your Web Applications With Async, Extensibility and More

http://slidepdf.com/reader/full/servlet-30-empowering-your-web-applications-with-async-extensibility-and 13/54

13

$ynamic registration o# Servlets and&iltersRegister ● 'er#ormed during Servlet7onte0t initiali;ation

● ServletConte!t4add5Servlet6Filter7

verloaded versions take <Servlet=&ilter> nameand● &ully :uali#ied <Servlet=&ilter> class name R

● Class)8 e!tends 5Servlet6Filter7  R

<Servlet=&ilter> instance● 6se returned %egistration handle to con#igure

all as%ects o# <Servlet=&ilter>

Page 14: Servlet 3.0:   Empowering Your Web   Applications With Async,   Extensibility and More

8/14/2019 Servlet 3.0: Empowering Your Web Applications With Async, Extensibility and More

http://slidepdf.com/reader/full/servlet-30-empowering-your-web-applications-with-async-extensibility-and 14/54

14

$ynamic registration o# Servlets and&ilters7reate and Register ● ServletConte!t4reate5Servlet6Filter7

● 9akes Class)8 e!tends 5Servlet6Filter7  argument

● 7ontainer res%onsible #or instantiating the5Servlet 6Filter7

● Su%%orts resource injection by container 

Returned[Servlet6Filter

]  instance may be#ully customi;ed be#ore it is registered via the

ServletConte!t4add5Servlet6Filter>methods

Page 15: Servlet 3.0:   Empowering Your Web   Applications With Async,   Extensibility and More

8/14/2019 Servlet 3.0: Empowering Your Web Applications With Async, Extensibility and More

http://slidepdf.com/reader/full/servlet-30-empowering-your-web-applications-with-async-extensibility-and 15/54

15 

$ynamic registration o# Servlets and&iltersLooku%● ServletConte!t4get5Servlet6Filter7%egistration

● 9akes <Servlet=&ilter> name as argument

● Returned %egistration handle %rovides subseto# con#iguration methods

● May only be used to add initiali;ation %arameters andma%%ings

●  Any con#licts returned as 9ava/util/Set 

Page 16: Servlet 3.0:   Empowering Your Web   Applications With Async,   Extensibility and More

8/14/2019 Servlet 3.0: Empowering Your Web Applications With Async, Extensibility and More

http://slidepdf.com/reader/full/servlet-30-empowering-your-web-applications-with-async-extensibility-and 16/54

16 

$ynamic registration o# Servlets/&ilters

Register "0am%leServlet%egistration/:-nami d-nami 3

  servletConte!t/addServlet$

  ;:-namiServlet;,;om/m-om/M-Servlet;'<

d-nami/addMapping$;.d-namiServlet;'<

d-nami/set0s-nSupported$true'<

Page 17: Servlet 3.0:   Empowering Your Web   Applications With Async,   Extensibility and More

8/14/2019 Servlet 3.0: Empowering Your Web Applications With Async, Extensibility and More

http://slidepdf.com/reader/full/servlet-30-empowering-your-web-applications-with-async-extensibility-and 17/54

17 

$ynamic registration o# Servlets/&ilters

Looku% "0am%leServlet%egistration delared 3

 servletConte!t/getServlet%egistration$;:elar

edServlet;'<

delared/addMapping$;.delaredServlet;'<

delared/setInitParameter$;param;, ;value;'<

Page 18: Servlet 3.0:   Empowering Your Web   Applications With Async,   Extensibility and More

8/14/2019 Servlet 3.0: Empowering Your Web Applications With Async, Extensibility and More

http://slidepdf.com/reader/full/servlet-30-empowering-your-web-applications-with-async-extensibility-and 18/54

18 

 Agenda

● vervie!

● "ase o# $evelo%ment

$ynamic registration o# Servlets and &ilters● 'luggability

●  Asynchronous su%%ort

Security enhancements● Miscellaneous

Page 19: Servlet 3.0:   Empowering Your Web   Applications With Async,   Extensibility and More

8/14/2019 Servlet 3.0: Empowering Your Web Applications With Async, Extensibility and More

http://slidepdf.com/reader/full/servlet-30-empowering-your-web-applications-with-async-extensibility-and 19/54

19

'luggability

● "nable use o# libraries and #rame!ork !ithoutboiler %late con#iguration in de%loymentdescri%tors

● 'ut the burden on the #rame!ork develo%er ● Modulari;e *eb/!ml to allo! #rame!orks to be

sel#?contained !ithin their o!n JAR #ile

'rogrammatic con#iguration A'+s● 6se o# annotations

Page 20: Servlet 3.0:   Empowering Your Web   Applications With Async,   Extensibility and More

8/14/2019 Servlet 3.0: Empowering Your Web Applications With Async, Extensibility and More

http://slidepdf.com/reader/full/servlet-30-empowering-your-web-applications-with-async-extensibility-and 20/54

20 

'luggability

Motivation #or !eb)0ml modulari;ation● 6se o# #rame!ork re:uires 2%ossibly com%le03

con#iguration in *eb/!ml

● &or e0am%le

● $eclare a controller Servlet

● Logging and security &ilters

● $eclare Listeners to %er#orm actions at various

%oints in the li#ecycle o# the a%%lication● 7an get com%le0 as de%endencies increase

● &rame!orks also need to document all thecon#iguration that needs to be done

Page 21: Servlet 3.0:   Empowering Your Web   Applications With Async,   Extensibility and More

8/14/2019 Servlet 3.0: Empowering Your Web Applications With Async, Extensibility and More

http://slidepdf.com/reader/full/servlet-30-empowering-your-web-applications-with-async-extensibility-and 21/54

21

'luggability

!eb?#ragment)0ml● *eb+fragment/!ml is descri%tor #or #rame!ork /

library

● +ncluded in M=>0+I?F directory

● 7ontainer res%onsible #or discovering #ragments andassembling the e##ective de%loyment descri%tor 

●  Almost identical to *eb/!ml

● rdering related elements di##erent

● nly JAR #iles in W=+I?F.lib considered as#ragments

Page 22: Servlet 3.0:   Empowering Your Web   Applications With Async,   Extensibility and More

8/14/2019 Servlet 3.0: Empowering Your Web Applications With Async, Extensibility and More

http://slidepdf.com/reader/full/servlet-30-empowering-your-web-applications-with-async-extensibility-and 22/54

22 

'luggability

!eb?#ragment)0ml e0am%le )*eb+fragment 

  )servlet 

  )servlet+name*elome).servlet+name 

  )servlet+lassom/m-om/WelomeServlet).servlet+lass 

  ).servlet 

  )servlet+mapping 

  )servlet+name*elome).servlet+name 

  )url+pattern.Welome).url+pattern 

  ).servlet+mapping 

  ///

 ).*eb+fragment 

Page 23: Servlet 3.0:   Empowering Your Web   Applications With Async,   Extensibility and More

8/14/2019 Servlet 3.0: Empowering Your Web Applications With Async, Extensibility and More

http://slidepdf.com/reader/full/servlet-30-empowering-your-web-applications-with-async-extensibility-and 23/54

23

'luggabilityrdering

● 7om%atible !ith JavaServer ™ &aces

● &ragments identi#ied by )name 

●   *eb/!ml may declare absolute ordering o#

#ragments via )absolute+ordering ● &ragments may declare ordering %re#erences

relative to other #ragments via )ordering  !ithnested )before  and )after 

8 +gnored i# )absolute+ordering  s%eci#ied

● S%ecial )otAers.  element moves #ragment tobeginning or end o# list o# sorted #ragments

Page 24: Servlet 3.0:   Empowering Your Web   Applications With Async,   Extensibility and More

8/14/2019 Servlet 3.0: Empowering Your Web Applications With Async, Extensibility and More

http://slidepdf.com/reader/full/servlet-30-empowering-your-web-applications-with-async-extensibility-and 24/54

24

'luggability

Resource sharing● Static and JavaServer ™ 'ages 2JS'3 resources

no longer con#ined to !eb a%%lication@s documentroot

● May be %laced inside W=+I?F.lib.5B/9ar7. M=>0+I?F.resoures

● 7ontainer must honor this ne! location !hen

%rocessing 99' re:uests and calls toServletConte!t4get%esoure50sStream7

● Resources in document root take %recedenceover those in bundled JAR #iles

Page 25: Servlet 3.0:   Empowering Your Web   Applications With Async,   Extensibility and More

8/14/2019 Servlet 3.0: Empowering Your Web Applications With Async, Extensibility and More

http://slidepdf.com/reader/full/servlet-30-empowering-your-web-applications-with-async-extensibility-and 25/54

25 

'luggability

Resource sharingB "0am%le m-*ebapp/*ar %ackagingB

  .inde!/9sp

  .W=+I?F.lib.sAared/9ar.M=>0+I?F.resoures.sAared/9sp

Re:uest #orB

AttpD..loalAostDEE.m-*ebapp.sAared/9s

!ill be served #rom:

  .patA.to.m-*ebapp.W=+I?F.lib.sAared/9ar.M=>0+I?F.resoures.sAared/9sp

Page 26: Servlet 3.0:   Empowering Your Web   Applications With Async,   Extensibility and More

8/14/2019 Servlet 3.0: Empowering Your Web Applications With Async, Extensibility and More

http://slidepdf.com/reader/full/servlet-30-empowering-your-web-applications-with-async-extensibility-and 26/54

26 

'luggability

Shared libraries● Su%%ort %lugging in o# container installed JAR

#iles

● "0am%lesB JS&, JAC?WS, S%ring

● Libraries may %rovide im%lementation o#ServletContainerInitialier

● Looked u% via the JAR Services A'+ in J$D 1

● +nvoked be#ore any Listeners during theinitiali;ation o# the a%%lication

Page 27: Servlet 3.0:   Empowering Your Web   Applications With Async,   Extensibility and More

8/14/2019 Servlet 3.0: Empowering Your Web Applications With Async, Extensibility and More

http://slidepdf.com/reader/full/servlet-30-empowering-your-web-applications-with-async-extensibility-and 27/54

27 

'luggability

Shared libraries 2contd3● ServletContainerInitialier e0%resses

interest in 7lasses via @Handles>-pes

7ontainer discovers classes that match@Handles>-pes and %asses them toServletContainerInitialier

● ServletContainerInitialier ins%ects

%assed in 7lasses and may register Servlets and&ilters based on them

Page 28: Servlet 3.0:   Empowering Your Web   Applications With Async,   Extensibility and More

8/14/2019 Servlet 3.0: Empowering Your Web Applications With Async, Extensibility and More

http://slidepdf.com/reader/full/servlet-30-empowering-your-web-applications-with-async-extensibility-and 28/54

28 

'luggability

Servlet7ontainer+nitiali;er e0am%le@Handles>-pes$WebServie/lass'

ubli lass 0WSInitialier implementsServletContainerInitialier "

  publi void onStartup$Set)Class)8 ,ServletConte!t t!'

"

  t!/addServlet$10WSServlet2,

1om/sun/9a!*s/0WSServlet2'<

(

(

Page 29: Servlet 3.0:   Empowering Your Web   Applications With Async,   Extensibility and More

8/14/2019 Servlet 3.0: Empowering Your Web Applications With Async, Extensibility and More

http://slidepdf.com/reader/full/servlet-30-empowering-your-web-applications-with-async-extensibility-and 29/54

29

 Agenda

● vervie!

● "ase o# $evelo%ment

$ynamic registration o# Servlets and &ilters● 'luggability

●  Asynchronous su%%ort

Security enhancements● Miscellaneous

Page 30: Servlet 3.0:   Empowering Your Web   Applications With Async,   Extensibility and More

8/14/2019 Servlet 3.0: Empowering Your Web Applications With Async, Extensibility and More

http://slidepdf.com/reader/full/servlet-30-empowering-your-web-applications-with-async-extensibility-and 30/54

30 

Why Asynchronous ServletsE

● 4ot #or Async +F

● Re:uests mostly small 2single %acket3

● ard to asynchronously %roduce large res%onses

●  Async + su%%ort !aiting #or 4+ 2Servlet ()-E3

●  Async Servlets are #orB

● Waiting #or resources 2eg J$57 connection3● Waiting #or events 2eg 7hat3

● Waiting #or res%onses 2eg !eb services, oS3

Page 31: Servlet 3.0:   Empowering Your Web   Applications With Async,   Extensibility and More

8/14/2019 Servlet 3.0: Empowering Your Web Applications With Async, Extensibility and More

http://slidepdf.com/reader/full/servlet-30-empowering-your-web-applications-with-async-extensibility-and 31/54

31

5locking !aiting consumes resources

● Web A%%lication using remote !eb services

● andling -*** re:uests / sec

● .*H re:uests call remote !eb service

● .** threads in container thread %ool

● +# remote !eb service is slo! 2-***ms3

● 9hread starvation in - secondF● .*H o# re:uests use all .** threads

Page 32: Servlet 3.0:   Empowering Your Web   Applications With Async,   Extensibility and More

8/14/2019 Servlet 3.0: Empowering Your Web Applications With Async, Extensibility and More

http://slidepdf.com/reader/full/servlet-30-empowering-your-web-applications-with-async-extensibility-and 32/54

32 

Waiting #or Web Services

5locking Asynchronous

9hread

blocked

WS re:uest+n %arallel

Page 33: Servlet 3.0:   Empowering Your Web   Applications With Async,   Extensibility and More

8/14/2019 Servlet 3.0: Empowering Your Web Applications With Async, Extensibility and More

http://slidepdf.com/reader/full/servlet-30-empowering-your-web-applications-with-async-extensibility-and 33/54

33

 Asynchronous A'+ServletRe:uest

● Servlet%e&uest4is0s-nSupported$'

● >rue i# ALL <&ilter=Servlet>s su%%ort async in

● the &ilter chain

the Re:uest$is%atch chain● 7on#igured in

● *eb/!ml 

● )as-n+supportedtrue).as-n+supported 

● With annotation● @WebServlet$as-nSupported3true'

● 'rogrammatic● registration/set0s-nSupported$boolean'

Page 34: Servlet 3.0:   Empowering Your Web   Applications With Async,   Extensibility and More

8/14/2019 Servlet 3.0: Empowering Your Web Applications With Async, Extensibility and More

http://slidepdf.com/reader/full/servlet-30-empowering-your-web-applications-with-async-extensibility-and 34/54

34

 Asynchronous A'+ServletRe:uest

● 0s-nConte!tServlet%e&uest4start0s-n$'

● 7alled by <&ilter=Servlet>

Res%onse is 49 commited on return o#B● Servlet/servie$re&uest,response'

● Filter chain

● 0s-nConte!t

Servlet%e&uest4start0s-n  $Servlet%e&uest re&,  Servlet%esponse res'

● Iariation that %reserves !ra%%ers

Page 35: Servlet 3.0:   Empowering Your Web   Applications With Async,   Extensibility and More

8/14/2019 Servlet 3.0: Empowering Your Web Applications With Async, Extensibility and More

http://slidepdf.com/reader/full/servlet-30-empowering-your-web-applications-with-async-extensibility-and 35/54

35 

 Asynchronous A'+ Async7onte0t

● 0s-nConte!t4dispatA$'

● 7alled by your asynchronous handler 

● Schedule async dis%atchB

:ispatAer>-pe/0SJ?C● Res%onse generated by <&ilter=Servlet> usingB

● container thread %ool

● JS', JS& or other #rame!orks usable

● J4$+, J9A, "J5s usable

● 0s-nConte!t4dispatA$String patA'

● Iariation to async dis%atch to s%eci#ic Servlet

Page 36: Servlet 3.0:   Empowering Your Web   Applications With Async,   Extensibility and More

8/14/2019 Servlet 3.0: Empowering Your Web Applications With Async, Extensibility and More

http://slidepdf.com/reader/full/servlet-30-empowering-your-web-applications-with-async-extensibility-and 36/54

36 

 Asynchronous A'+

 Async7onte0t● 0s-nConte!t4omplete$'

● 7alled by your asynchronous handler 

Res%onse has been generated asynchronously● !ithout Servlet #eatures, or 

● !ith 0s-nConte!t4start$%unnable r' ● #or J4$+, classloader 

Page 37: Servlet 3.0:   Empowering Your Web   Applications With Async,   Extensibility and More

8/14/2019 Servlet 3.0: Empowering Your Web Applications With Async, Extensibility and More

http://slidepdf.com/reader/full/servlet-30-empowering-your-web-applications-with-async-extensibility-and 37/54

37 

 Asynchronous Web Service

Weba%%

doGet()

doGet()

s ta rtA s ync () WS call

dis pa tc h()

Server 

Page 38: Servlet 3.0:   Empowering Your Web   Applications With Async,   Extensibility and More

8/14/2019 Servlet 3.0: Empowering Your Web Applications With Async, Extensibility and More

http://slidepdf.com/reader/full/servlet-30-empowering-your-web-applications-with-async-extensibility-and 38/54

38 

Multi%le 6sage Styles

● start0s-n$' K dispatA$'

● Retry re:uest a#ter async !ait

● &ilters re?a%%lied i# on :ispatAer>-pe/0SJ?C

● start0s-n$' K dispatA$patA'

● 6se s%eci#ic Servlet handling a#ter async !ait

● start0s-n$' K omplete$'

● Generate res%onse asynchronously

Page 39: Servlet 3.0:   Empowering Your Web   Applications With Async,   Extensibility and More

8/14/2019 Servlet 3.0: Empowering Your Web Applications With Async, Extensibility and More

http://slidepdf.com/reader/full/servlet-30-empowering-your-web-applications-with-async-extensibility-and 39/54

39

Multi%le 6sage Styles

● start0s-n$re&,res'K dispatA$'● Retry re:uest a#ter async !ait

● Wra%%ers are ke%t

%e&uest:ispatAer4for*ard  target used

● start0s-n$re&,res'K dispatA$patA'

● S%eci#ic Servlet handling a#ter async !ait

● start0s-n$re&,res'K omplete$'

● Generate !ra%%ed res%onse asynchronously

Page 40: Servlet 3.0:   Empowering Your Web   Applications With Async,   Extensibility and More

8/14/2019 Servlet 3.0: Empowering Your Web Applications With Async, Extensibility and More

http://slidepdf.com/reader/full/servlet-30-empowering-your-web-applications-with-async-extensibility-and 40/54

40 

 Asynchronous A'+ $etails

● 9imeouts

● Servlet%e&uest4set0s-n>imeout$long ms'

● 5y de#ault error dis%atch on timeout

● Listeners

● 0s-nListener4n>imeout

8 0s-nListener4nComplete

Page 41: Servlet 3.0:   Empowering Your Web   Applications With Async,   Extensibility and More

8/14/2019 Servlet 3.0: Empowering Your Web Applications With Async, Extensibility and More

http://slidepdf.com/reader/full/servlet-30-empowering-your-web-applications-with-async-extensibility-and 41/54

41

$emonstration  Asynchronous e5ay Web Service

"o$ %ackaging

8 M"9A?+4&8 !eb?#ragment)0ml

8 Resources/K

Glass#ish 7ontainer 

8  Async Serlvet

Jetty 99' 7lient

8  Async 7lient

Page 42: Servlet 3.0:   Empowering Your Web   Applications With Async,   Extensibility and More

8/14/2019 Servlet 3.0: Empowering Your Web Applications With Async, Extensibility and More

http://slidepdf.com/reader/full/servlet-30-empowering-your-web-applications-with-async-extensibility-and 42/54

42 

 Agenda

● vervie!

● "ase o# $evelo%ment

$ynamic registration o# Servlets and &ilters● 'luggability

●  Asynchronous su%%ort

Security enhancements● Miscellaneous

Page 43: Servlet 3.0:   Empowering Your Web   Applications With Async,   Extensibility and More

8/14/2019 Servlet 3.0: Empowering Your Web Applications With Async, Extensibility and More

http://slidepdf.com/reader/full/servlet-30-empowering-your-web-applications-with-async-extensibility-and 43/54

43

Security Security constraints via common annotations

● Su%%ort #or common annotations

● @%oles0llo*ed  ? autA+onstraint !ith roles

● @:en-0ll ? "m%ty autA+onstraint

● @Permit0ll ? 4o autA+onstraint 

● @>ransportProteted  ? user+data+onstraint

●  Annotations en#orced on 9ava!/Attp/Servlet 

class and do methods o# HttpServlet

● Method?targeted annotations take %recedence overclass?targeted annotations

Page 44: Servlet 3.0:   Empowering Your Web   Applications With Async,   Extensibility and More

8/14/2019 Servlet 3.0: Empowering Your Web Applications With Async, Extensibility and More

http://slidepdf.com/reader/full/servlet-30-empowering-your-web-applications-with-async-extensibility-and 44/54

44

Security Security constraints via common annotations 2contd3

● Security constraints in *eb/!ml overrideannotations, metdata+omplete disablesannotations

● *eb+resoure+olletion enhanced !ith Attp+ metAod+omission to

●  Allo! constraints to be s%eci#ied on non?enumerable 99' method subsets 2i)e), allother methods3

Page 45: Servlet 3.0:   Empowering Your Web   Applications With Async,   Extensibility and More

8/14/2019 Servlet 3.0: Empowering Your Web Applications With Async, Extensibility and More

http://slidepdf.com/reader/full/servlet-30-empowering-your-web-applications-with-async-extensibility-and 45/54

45 

Security 'rogrammatic container authentication and logout

● HttpServlet%e&uest4login$String username,String pass*ord'

● Re%lacement #or &5L

●  A%%lication su%ervises credential collection● HttpServlet%e&uest4autAentiate$HttpServlet%esponse'

 A%%lication initiates container mediatedauthentication #rom a resource that is notcovered by any authentication constraints

●  A%%lication decides !hen authentication must

occur

Page 46: Servlet 3.0:   Empowering Your Web   Applications With Async,   Extensibility and More

8/14/2019 Servlet 3.0: Empowering Your Web Applications With Async, Extensibility and More

http://slidepdf.com/reader/full/servlet-30-empowering-your-web-applications-with-async-extensibility-and 46/54

46 

Security'rogrammatic container authentication and logout

2contd3● HttpServlet%e&uest4logout

● +ntegration o# additional container authentication

modules via Servlet 'ro#ile o# JSR -1recommended

Page 47: Servlet 3.0:   Empowering Your Web   Applications With Async,   Extensibility and More

8/14/2019 Servlet 3.0: Empowering Your Web Applications With Async, Extensibility and More

http://slidepdf.com/reader/full/servlet-30-empowering-your-web-applications-with-async-extensibility-and 47/54

47 

 Agenda

● vervie!

● "ase o# $evelo%ment

$ynamic registration o# Servlets and &ilters● 'luggability

●  Asynchronous su%%ort

Security enhancements● Miscellaneous

Page 48: Servlet 3.0:   Empowering Your Web   Applications With Async,   Extensibility and More

8/14/2019 Servlet 3.0: Empowering Your Web Applications With Async, Extensibility and More

http://slidepdf.com/reader/full/servlet-30-empowering-your-web-applications-with-async-extensibility-and 48/54

48 

Miscellaneous &eatures / A'+s

● Session tracking cookie con#iguration

● Iia *eb/!ml

● 'rogrammatic via9ava!/servlet/SessionCooieConfig

● Su%%ort #or Httpnl- cookie attribute

● "0am%leB 

servletConte!t/getSessionCooieConfig$'/setHttpnl-$true'

● $e#ault error %age

Page 49: Servlet 3.0:   Empowering Your Web   Applications With Async,   Extensibility and More

8/14/2019 Servlet 3.0: Empowering Your Web Applications With Async, Extensibility and More

http://slidepdf.com/reader/full/servlet-30-empowering-your-web-applications-with-async-extensibility-and 49/54

49

Miscellaneous &eatures / A'+s 2contd3

Servlet%e&uest4getServletConte!t

Servlet%e&uest4get:ispatAer>-pe

Servlet5%e&uest6%esponse7Wrapper4isWrapperFor

HttpServlet%esponse4getStatus

HttpServlet%esponse4getHeader

HttpServlet%esponse4getHeaders

HttpServlet%esponse4getHeader?ames

Page 50: Servlet 3.0:   Empowering Your Web   Applications With Async,   Extensibility and More

8/14/2019 Servlet 3.0: Empowering Your Web Applications With Async, Extensibility and More

http://slidepdf.com/reader/full/servlet-30-empowering-your-web-applications-with-async-extensibility-and 50/54

50 

Miscellaneous &eatures / A'+s 2contd3&ile u%load A'+s

Servlet%e&uest4getParts

Servlet%e&uest4getPart

@MultipartConfig7hanges to *eb/!ml

Page 51: Servlet 3.0:   Empowering Your Web   Applications With Async,   Extensibility and More

8/14/2019 Servlet 3.0: Empowering Your Web Applications With Async, Extensibility and More

http://slidepdf.com/reader/full/servlet-30-empowering-your-web-applications-with-async-extensibility-and 51/54

51

Summary

● Major revision since Servlet )

● 7om%rehensive set o# ne! #eatures enablemodern style o# !eb a%%lications and greatly

increases develo%er %roductivity● Sim%li#ies assembly o# large a%%lications #rom

reusable com%onents

Page 52: Servlet 3.0:   Empowering Your Web   Applications With Async,   Extensibility and More

8/14/2019 Servlet 3.0: Empowering Your Web Applications With Async, Extensibility and More

http://slidepdf.com/reader/full/servlet-30-empowering-your-web-applications-with-async-extensibility-and 52/54

52 

Glass&ish 7ommunity%en Source and "nter%rise Ready

● GlassFish V3 Preview Available now!● Java "" 1 re#erence im%lementation● Modular SGi architecture easy to develo% N de%loy● Runs in?%rocess and easy to e0tend● Su%%ort #or Ruby?on?Rails, Groovy and Grails,

'ython and $jango● GlassFish V2 – Production Ready● 5est %rice/%er#ormance o%en source A%% server !ith

7lustering, igh Availability, Load 5alancing● Secure, Reliable, 9ransactional, )4"9?intero% Web svcs● Su%%ort #or Aja0 and 7omet

● GlassFish ES● SA and 5usiness +ntegration %lat#orm

● GlassFish o""unications A## Server ● S+' servlet technology #or converged services

O 24x7 Enterprise and MissionCritical Support

Osun.com/glassfish

O Tools IntegrationONetBeans and Eclipse

glassfish.org

Ala!s free to download, deploy and distribute

Page 53: Servlet 3.0:   Empowering Your Web   Applications With Async,   Extensibility and More

8/14/2019 Servlet 3.0: Empowering Your Web Applications With Async, Extensibility and More

http://slidepdf.com/reader/full/servlet-30-empowering-your-web-applications-with-async-extensibility-and 53/54

53

Webtide N Jetty

Status u%date

htt%B//ecli%se)org/jetty

Page 54: Servlet 3.0:   Empowering Your Web   Applications With Async,   Extensibility and More

8/14/2019 Servlet 3.0: Empowering Your Web Applications With Async, Extensibility and More

http://slidepdf.com/reader/full/servlet-30-empowering-your-web-applications-with-async-extensibility-and 54/54

Rajiv Mordani

rajiv)mordaniPsun)comJan Luehe

 jan)luehePsun)comGreg Wilkins