HTTP/2 Comes to Java - What Servlet 4.0 Means to You

David Delabassee
David DelabasseeDevRel - Java Platform Group - Oracle
HTTP/2 
Comes 
to 
Java 
What 
Servlet 
4.0 
Means 
to 
You 
JAZOON 
2014 
David 
Delabassee 
(@delabassee) 
Oracle 
Copyright 
© 
2014, 
Oracle 
and/or 
its 
affiliates. 
All 
rights 
reserved. 
|
Safe 
Harbor 
Statement 
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. 
Copyright 
© 
2014, 
Oracle 
and/or 
its 
affiliates. 
All 
rights 
reserved. 
| 
2
Copyright 
© 
2014, 
Oracle 
and/or 
its 
affiliates. 
All 
rights 
reserved. 
| 
Agenda 
Java 
EE 
8 
Why 
HTTP/2? 
HTTP/2 
Big 
Features 
How 
Servlet 
Might 
Expose 
These 
Features 
Java 
SE 
9 
Support 
for 
HTTP/2 
Summary 
and 
Current 
Status 
3
Copyright 
© 
2014, 
Oracle 
and/or 
its 
affiliates. 
All 
rights 
reserved. 
| 
Agenda 
Java 
EE 
8 
Why 
HTTP/2? 
HTTP/2 
Big 
Features 
How 
Servlet 
Might 
Expose 
These 
Features 
Java 
SE 
9 
Support 
for 
HTTP/2 
Summary 
and 
Current 
Status 
4
DEVELOPER 
PRODUCTIVITY 
Copyright 
© 
2014, 
Oracle 
and/or 
its 
affiliates. 
All 
rights 
reserved. 
Java 
EE 
7 
ENTERPRISE 
EDITION 
▪Batch 
▪Concurrency 
▪Simplified JMS 
▪More annotated POJOs 
▪Less boilerplate code 
▪Cohesive integrated platform 
▪WebSockets 
▪JSON 
▪Servlet 3.1 NIO 
▪REST 
MEETING 
ENTERPRISE 
DEMANDS 
Java EE 7 
5
Industry 
Trends 
We're 
Seeing 
Reactive 
Programming 
Copyright 
© 
2014, 
Oracle 
and/or 
its 
affiliates. 
All 
rights 
reserved. 
Cloud 
Mobile 
HTTP/2 
SECURITY 
User 
Experience 
6
Java 
EE 
8 
Community 
Survey 
Copyright 
© 
2014, 
Oracle 
and/or 
its 
affiliates. 
All 
rights 
reserved. 
• 3 
parts 
over 
3½ 
months 
– 47 
questions 
– 15 
fill-­‐ins 
– 1000’s 
of 
comments 
• 4500+ 
respondents 
• Prioritization 
of 
most-­‐popular 
features 
7
Copyright 
© 
2014, 
Oracle 
and/or 
its 
affiliates. 
All 
rights 
reserved.
Community-­‐Prioritized 
Features 
Copyright 
© 
2014, 
Oracle 
and/or 
its 
affiliates. 
All 
rights 
reserved. 
9
Copyright 
© 
2014, 
Oracle 
and/or 
its 
affiliates. 
All 
rights 
reserved. 
Java 
EE 
8 
Themes 
• HTML5 
/ 
Web 
Tier 
Enhancements 
• Infrastructure 
for 
running 
in 
the 
Cloud 
• Ease 
of 
Development 
/ 
CDI 
alignment 
10
Ease 
of 
Development 
/ 
CDI 
Alignment 
Copyright 
© 
2014, 
Oracle 
and/or 
its 
affiliates. 
All 
rights 
reserved. 
• Security 
interceptors 
• Simplified 
messaging 
through 
CDI-­‐based 
“MDBs” 
• JAX-­‐RS 
injection 
alignment 
• WebSocket 
scopes 
• Pruning 
of 
EJB 
2.x 
client 
view 
and 
IIOP 
interoperability 
11
Modernize 
the 
Infrastructure 
For 
On-­‐Premise 
and 
for 
in 
the 
Cloud 
Copyright 
© 
2014, 
Oracle 
and/or 
its 
affiliates. 
All 
rights 
reserved. 
• Java 
EE 
Management 
2.0 
– REST-­‐based 
APIs 
for 
Management 
and 
Deployment 
• Java 
EE 
Security 
1.0 
– Authorization 
– Password 
Aliasing 
– User 
Management 
– Role 
Mapping 
– Authentication 
– REST 
Authentication 
12
HTML5 
Support 
/ 
Web 
Tier 
Enhancements 
Copyright 
© 
2014, 
Oracle 
and/or 
its 
affiliates. 
All 
rights 
reserved. 
• JSON 
Binding 
• JSON 
Processing 
enhancements 
• Server-­‐sent 
events 
• Action-­‐based 
MVC 
• HTTP/2 
support 
13
Copyright 
© 
2014, 
Oracle 
and/or 
its 
affiliates. 
All 
rights 
reserved. 
Java 
EE 
8 
JSRs 
• Java 
EE 
8 
Platform 
• CDI 
2.0 
• JSON 
Binding 
1.0 
• JAX-­‐RS 
2.1 
• MVC 
1.0 
• Java 
Servlet 
4.0 
• JSF 
2.3 
• JMS 
2.1 
• JSON-­‐P 
1.1 
• Java 
EE 
Security 
1.0 
• Java 
EE 
Management 
2.0 
• … 
and 
more 
to 
follow 
… 
So 
far….. Coming 
soon 
….. 
14
Copyright 
© 
2014, 
Oracle 
and/or 
its 
affiliates. 
All 
rights 
reserved. 
| 
Agenda 
Java 
EE 
8 
Why 
HTTP/2? 
HTTP/2 
Big 
Features 
How 
Servlet 
Might 
Expose 
These 
Features 
Java 
SE 
9 
Support 
for 
HTTP/2 
Summary 
and 
Current 
Status 
15
. 
. 
. 
Copyright 
© 
2014, 
Oracle 
and/or 
its 
affiliates. 
All 
rights 
reserved. 
| 
A 
Real 
Life 
Example 
index.html 
style1.css 
style2.css 
script1.js 
. 
. 
. 
script9.js 
pic1.jpg 
pic8.jpg 
photo1.png 
photo2.png 
. 
. 
.
Client Server 
Copyright 
© 
2014, 
Oracle 
and/or 
its 
affiliates. 
All 
rights 
reserved. 
| 
Problems 
in 
HTTP 
1.1 
• HTTP 
Pipelining 
• Head-­‐of-­‐Line 
blocking 
index.html 
style1.css 
style2.css 
index.html 
style1.css 
style2.css 
script1.js 
script2.js 
. 
. 
. 
script1.js 
script2.js 
. 
. 
.
Copyright 
© 
2014, 
Oracle 
and/or 
its 
affiliates. 
All 
rights 
reserved. 
| 
• Inefficient 
use 
of 
TCP 
sockets 
Client Server Client Server 
Client Server 
Client Server 
Client Server 
Client Server 
Problems 
in 
HTTP 
1.1
Copyright 
© 
2014, 
Oracle 
and/or 
its 
affiliates. 
All 
rights 
reserved. 
| 
At 
the 
beginning… 
19 
<img/>
File 
Concatenation 
and 
Image 
Sprites 
TCP 
Efficiency 
Improves 
with 
Larger 
Files 
Copyright 
© 
2014, 
Oracle 
and/or 
its 
affiliates. 
All 
rights 
reserved. 
| 
20 
• Modern 
web 
page 
now 
consists 
of 
more 
than 
90 
resources 
fetched 
from 
15 
distinct 
hosts 
- http://httparchive.org 
• Solution 
– Shoving 
more 
than 
one 
logical 
file 
into 
one 
physical 
file
File 
Concatenation 
and 
Image 
Sprites 
TCP 
Efficiency 
Improves 
with 
Larger 
Files 
Copyright 
© 
2014, 
Oracle 
and/or 
its 
affiliates. 
All 
rights 
reserved. 
| 
21 
.ic-­‐AerospaceAndDefense-­‐wht-­‐on-­‐gray, 
.ic-­‐AerospaceAndDefense-­‐wht-­‐on-­‐red, 
.ic-­‐ 
Airline-­‐wht-­‐on-­‐gray, 
.ic-­‐Airline-­‐wht-­‐on-­‐red{ 
background: 
url(sprites.png) 
no-­‐repeat; 
} 
.ic-­‐AerospaceAndDefense-­‐wht-­‐on-­‐gray{ 
background-­‐position: 
0 
0; 
width: 
80px; 
height: 
80px; 
} 
.ic-­‐AerospaceAndDefense-­‐wht-­‐on-­‐red{ 
background-­‐position: 
-­‐81px 
0; 
width: 
80px; 
height: 
80px; 
} 
.ic-­‐Airline-­‐wht-­‐on-­‐gray{ 
background-­‐position: 
0 
-­‐80px 
; 
width: 
80px; 
height: 
80px; 
} 
.ic-­‐Airline-­‐wht-­‐on-­‐red{ 
background-­‐position: 
-­‐81px 
-­‐79px 
; 
width: 
80px; 
height: 
80px; 
}
File 
Concatenation 
and 
Image 
Sprites 
TCP 
Efficiency 
Improves 
with 
Larger 
Files 
Copyright 
© 
2014, 
Oracle 
and/or 
its 
affiliates. 
All 
rights 
reserved. 
| 
22
Domain 
Sharding 
Split 
page 
resources 
across 
several 
hosts 
to 
work 
around 
browser 
limits 
Copyright 
© 
2014, 
Oracle 
and/or 
its 
affiliates. 
All 
rights 
reserved. 
| 
23
Copyright 
© 
2014, 
Oracle 
and/or 
its 
affiliates. 
All 
rights 
reserved. 
| 
Inlined 
Assets 
Base64 
Encoding 
Will 
Never 
Die 
• data 
URLs 
• <img 
src="data:image/gif;base64,R0lGODlhEAAOALMAAOazToeHh0tLS/ 
7LZv0jvb29tf3Ubge8WSLrhf3kdbW1mxsbPmfyH5BAAAjAAAALAAfhGHhcjA 
AAAQAA4lsjkhfkjfhGHhcjGDSHJUYgJvhgtyrHgfGfHyt56HGfGH56ge8WSLf6G 
GHvvhdsbxusbaOiQA4lsjkhfkjf4lsjkhfkjf4lsjkhfkjfhfkjfhpBREzxvt6QAA4lsjkhf 
kjfhdxwqBnuIoYtyGhBKoOjJj6GGHvvhdsbxus38GV3DcPjjBceXsplojj…” 
/> 
24
Copyright 
© 
2014, 
Oracle 
and/or 
its 
affiliates. 
All 
rights 
reserved. 
| 
• HTTP 
uses 
TCP 
poorly 
- HTTP 
flows 
are 
short 
and 
bursty 
- TCP 
was 
built 
for 
long-­‐lived 
flows 
• Solutions 
– Sprites 
– Domain 
sharding 
– Assets 
Inlining 
– File 
concatenations 
– … 
25 
HTTP 
1.1 
circa 
1999 
Problems 
Vs 
Solutions
Copyright 
© 
2014, 
Oracle 
and/or 
its 
affiliates. 
All 
rights 
reserved. 
| 
• “Conversion 
Rate” 
Vs 
Latency 
- 1 
in 
4 
people 
abandons 
surfing 
to 
a 
site 
if 
the 
page 
takes 
longer 
than 
4 
seconds 
to 
loads 
- Page 
load 
slowdown 
of 
1 
second 
could 
cost 
Amazon 
$1.6 
billion 
in 
sales 
each 
year 
- Slowing 
search 
results 
by 
just 
4/10 
of 
a 
second, 
Google 
could 
lose 
8 
million 
searches 
per 
day 
- http://www.fastcompany.com/1825005/how-­‐one-­‐second-­‐could-­‐cost-­‐amazon-­‐16-­‐ 
billion-­‐sales 
26 
Time 
is 
Money!
Copyright 
© 
2014, 
Oracle 
and/or 
its 
affiliates. 
All 
rights 
reserved. 
| 
google.fr 
(1st) 
• 3 
HTTP 
Requests 
• 21.355 
bytes 
- 1 
HTML 
- 1 
image 
- 1 
? 
27 
Top 
.FR 
examples 
lefigaro.fr 
(15th) 
• 140 
HTTP 
Requests 
• 2.736.562 
bytes 
- 1 
HTML 
- 130 
images 
- 6 
.js 
- 2 
.css 
- 1 
?
Copyright 
© 
2014, 
Oracle 
and/or 
its 
affiliates. 
All 
rights 
reserved. 
| 
Agenda 
Java 
EE 
8 
Why 
HTTP/2? 
HTTP/2 
Big 
Features 
How 
Servlet 
Might 
Expose 
These 
Features 
Java 
SE 
9 
Support 
for 
HTTP/2 
Summary 
and 
Current 
Status 
28
Copyright 
© 
2014, 
Oracle 
and/or 
its 
affiliates. 
All 
rights 
reserved. 
| 
29 
HTTP/2 
Big 
Ticket 
Features 
Review 
• Binary 
Framing 
• Request/Response 
multiplexing 
• Stream 
Prioritization 
• Server 
Push 
• Header 
Compression 
• Upgrade 
from 
HTTP 
1.1 
- ALPN 
(or 
NPN) 
- 101 
Switching 
Protocols
HTTP/2 
Request 
Response 
Multiplexing 
Copyright 
© 
2014, 
Oracle 
and/or 
its 
affiliates. 
All 
rights 
reserved. 
| 
• Fully 
bi-­‐directional 
– Connection 
A 
TCP 
socket 
– Stream 
A 
“channel” 
within 
a 
connection 
– Message 
A 
logical 
message, 
such 
as 
a 
request 
or 
a 
response 
– Frame 
The 
smallest 
unit 
of 
communication 
in 
HTTP/2 
30 
Lets 
you 
do 
more 
things 
with 
a 
single 
TCP 
connection
HTTP/2 
Request 
Response 
Multiplexing 
Copyright 
© 
2014, 
Oracle 
and/or 
its 
affiliates. 
All 
rights 
reserved. 
| 
31 
Connections, 
Streams, 
Messages, 
Frames
HTTP/2 
Request 
Response 
Multiplexing 
Copyright 
© 
2014, 
Oracle 
and/or 
its 
affiliates. 
All 
rights 
reserved. 
| 
• Communication 
broken 
into 
frames 
• Logical 
streams 
can 
be 
interweaved 
over 
a 
single 
TCP 
connection 
32 
Connections, 
Streams, 
Messages, 
Frames
Copyright 
© 
2014, 
Oracle 
and/or 
its 
affiliates. 
All 
rights 
reserved. 
| 
HTTP/2 
Binary 
Framing 
• Frame 
Header 
! 
• Types 
- HEADERS, 
DATA, 
PRIORITY, 
RST_STREAM, 
SETTINGS, 
PUSH_PROMISE, 
PING, 
GOAWAY, 
WINDOW_UPDATE, 
CONTINUATION 
33 
Enabled 
by 
dumping 
newline 
delimited 
ASCII 
Length 
(24) 
Type 
(8) Flags 
(8) 
R Stream 
Identifier 
(31) 
Frame 
Payload 
(0 
…)
Copyright 
© 
2014, 
Oracle 
and/or 
its 
affiliates. 
All 
rights 
reserved. 
| 
HTTP/2 
Binary 
Framing 
GET 
/index.html 
HTTP/1.1 
Host: 
example.com 
Accept: 
text/html 
34 
Example 
1 
HEADERS 
+ 
END_STREAM 
+ 
END_HEADERS 
:method: 
GET 
:scheme: 
http 
:path: 
/index.html 
:authority: 
example.org 
accept: 
text/html
Copyright 
© 
2014, 
Oracle 
and/or 
its 
affiliates. 
All 
rights 
reserved. 
| 
HTTP/2 
Binary 
Framing 
HTTP/1.1 
200 
OK 
Content-­‐Length: 
11 
Content-­‐Type: 
text/html 
Hello 
World 
35 
Example 
2 
HEADERS 
-­‐ 
END_STREAM 
+ 
END_HEADERS 
:status: 
200 
content-­‐length: 
11 
content-­‐type: 
text/html 
DATA 
+ 
END_STREAM 
Hello 
World
Copyright 
© 
2014, 
Oracle 
and/or 
its 
affiliates. 
All 
rights 
reserved. 
| 
HTTP/2 
Stream 
Prioritization 
• Stream 
Dependency 
in 
HEADERS 
Frame 
• PRIORITY 
frame 
type 
• An 
additional 
40 
bytes 
– Stream 
id 
(31) 
–Weight 
(8): 
[1, 
256] 
– Exclusive 
bit 
(1) 
• Only 
an 
advice 
36 
A 
B C 
4 12 
A 
B D C 
4 16 12 
exclusive 
= 
0 
A 
D 
16 
B C 
4 12 
exclusive 
= 
1
Copyright 
© 
2014, 
Oracle 
and/or 
its 
affiliates. 
All 
rights 
reserved. 
| 
HTTP/2 
Server 
Push 
• Eliminates 
the 
need 
for 
resource 
inlining 
• Lets 
the 
server 
populate 
the 
browser’s 
cache 
in 
advance 
of 
the 
browser 
asking 
for 
the 
resource 
to 
put 
in 
the 
cache 
• No 
corresponding 
JavaScript 
API 
• Can 
be 
combined 
with 
SSE 
– Server 
pushes 
stuff 
into 
the 
browser’s 
cache 
– Server 
uses 
SSE 
to 
tell 
the 
browser 
to 
go 
fetch 
it 
37
HTTP/2 
Header 
Compression 
Copyright 
© 
2014, 
Oracle 
and/or 
its 
affiliates. 
All 
rights 
reserved. 
| 
• Most 
of 
the 
headers 
are 
the 
same 
in 
a 
given 
stream 
– Host: 
Accept: 
user-­‐agent: 
etc. 
–Why 
send 
them 
every 
time? 
• Server 
and 
the 
client 
keep 
tables 
of 
headers 
– Send 
tables 
references 
and 
updates 
38 
Known 
as 
HPACK
HTTP/2 
Header 
Compression 
Copyright 
© 
2014, 
Oracle 
and/or 
its 
affiliates. 
All 
rights 
reserved. 
| 
39
HTTP/2 
Upgrade 
from 
HTTP 
1.1 
Copyright 
© 
2014, 
Oracle 
and/or 
its 
affiliates. 
All 
rights 
reserved. 
| 
• Not 
secure 
– Port 
80 
– HTTP 
1.1 
101 
Protocol 
Switching 
• Secure 
– Next 
Protocol 
Negotiation 
(NPN) 
– Application 
Layer 
Protocol 
Negotiation 
(ALPN) 
40 
Secure 
or 
not-­‐secure?
Copyright 
© 
2014, 
Oracle 
and/or 
its 
affiliates. 
All 
rights 
reserved. 
| 
Agenda 
Java 
EE 
8 
Why 
HTTP/2? 
HTTP/2 
Big 
Features 
How 
Servlet 
Might 
Expose 
These 
Features 
Java 
SE 
9 
Support 
for 
HTTP/2 
Summary 
and 
Current 
Status 
41
Copyright 
© 
2014, 
Oracle 
and/or 
its 
affiliates. 
All 
rights 
reserved. 
| 
Agenda 
Java 
EE 
8 
Why 
HTTP/2? 
HTTP/2 
Big 
Features 
How 
Servlet 
Might 
Expose 
These 
Features 
Java 
SE 
9 
Support 
for 
HTTP/2 
Summary 
and 
Current 
Status 
42
Servlet 
4.0 
Big 
Ticket 
New 
Features 
Copyright 
© 
2014, 
Oracle 
and/or 
its 
affiliates. 
All 
rights 
reserved. 
| 
• API 
was 
designed 
for 
“One 
Request 
== 
One 
Response” 
• HTTP/2 
destroys 
this 
assumption 
• It 
will 
be 
challenging 
to 
do 
justice 
to 
the 
new 
reality 
of 
“One 
Request 
== 
One 
or 
More 
Responses” 
• We 
must 
not 
simply 
bolt 
the 
“One 
or 
More 
Responses” 
concept 
onto 
some 
convenient 
part 
of 
the 
existing 
API 
43 
Challenges 
in 
Exposing 
HTTP/2 
Features 
in 
Servlet 
API
Copyright 
© 
2014, 
Oracle 
and/or 
its 
affiliates. 
All 
rights 
reserved. 
| 
• Request/Response 
multiplexing 
• Binary 
Framing 
• Stream 
Prioritization 
• Server 
Push 
• Header 
Compression 
• Upgrade 
from 
HTTP 
1.1 
– ALPN 
or 
(NPN) 
– 101 
Switching 
Protocols 
44 
Servlet 
4.0 
Big 
Ticket 
New 
Features
Servlet 
4.0 
Big 
Ticket 
New 
Features 
Copyright 
© 
2014, 
Oracle 
and/or 
its 
affiliates. 
All 
rights 
reserved. 
| 
• Request/Response 
Multiplexing 
• Binary 
Framing 
• Stream 
Prioritization 
• Server 
Push 
• Header 
Compression 
• Upgrade 
from 
HTTP 
1.1 
– ALPN 
or 
(NPN) 
– 101 
Switching 
Protocols 
45 
HTTP/2 
Features 
Potentially 
Exposed 
in 
Servlet 
API
Servlet 
4.0 
Big 
Ticket 
New 
Features 
Copyright 
© 
2014, 
Oracle 
and/or 
its 
affiliates. 
All 
rights 
reserved. 
| 
• Add 
method 
HttpServletRequest 
and 
HttpServletResponse 
– int 
getStreamId() 
46 
HTTP/2 
Features 
Potentially 
Exposed 
in 
Servlet 
API
Servlet 
4.0 
Big 
Ticket 
New 
Features 
Copyright 
© 
2014, 
Oracle 
and/or 
its 
affiliates. 
All 
rights 
reserved. 
| 
• Add 
a 
new 
class 
Priority 
– boolean 
exclusive 
– int 
streamId 
– int 
weight 
• Add 
method 
to 
HttpServletRequest 
– Priority 
getPriority() 
• Add 
methods 
to 
HttpServletResponse 
– Priority 
getPriority() 
– void 
setPriority(Priority 
p) 
47 
Stream 
Prioritization
Servlet 
4.0 
Big 
Ticket 
New 
Features 
Copyright 
© 
2014, 
Oracle 
and/or 
its 
affiliates. 
All 
rights 
reserved. 
| 
• Push 
resource 
to 
client 
for 
a 
given 
url 
and 
headers 
• May 
add 
callback 
for 
completion 
or 
error 
of 
a 
push 
• Not 
a 
replacement 
for 
WebSocket 
• Really 
useful 
for 
frameworks 
that 
build 
on 
Servlet, 
such 
as 
JSF 
48 
Server 
Push
Copyright 
© 
2014, 
Oracle 
and/or 
its 
affiliates. 
All 
rights 
reserved. 
| 
49
Copyright 
© 
2014, 
Oracle 
and/or 
its 
affiliates. 
All 
rights 
reserved. 
| 
Server 
Push 
Example 
of 
Potential 
Use 
from 
JSF 
public 
class 
FacesServlet 
implements 
Servlet 
{ 
public 
void 
service(ServletRequest 
req, 
ServletResponse 
resp) 
throws 
IOException, 
ServletException 
{ 
//.. 
HttpServletRequest 
request 
= 
(HttpServletRequest) 
req; 
try 
{ 
ResourceHandler 
handler 
= 
context.getApplication().getResourceHandler(); 
if 
(handler.isResourceRequest(context) 
|| 
request.isPushRequest()) 
{ 
handler.handleResourceRequest(context); 
} 
else 
{ 
lifecycle.attachWindow(context); 
lifecycle.execute(context); 
lifecycle.render(context); 
} 
} 
} 
50
Copyright 
© 
2014, 
Oracle 
and/or 
its 
affiliates. 
All 
rights 
reserved. 
| 
Server 
Push 
Example 
of 
Potential 
Use 
from 
JSF 
public 
class 
ExternalContextImpl 
extends 
ExternalContext 
{ 
//… 
public 
String 
encodeResourceURL(String 
url) 
{ 
if 
(null 
== 
url) 
{ 
String 
message 
= 
MessageUtils.getExceptionMessageString 
(MessageUtils.NULL_PARAMETERS_ERROR_MESSAGE_ID, 
"url"); 
throw 
new 
NullPointerException(message); 
} 
Map 
attrs 
= 
getResourceAttrs(); 
((HttpServletRequest) 
request).dispatchPushRequest(url, 
attrs); 
return 
((HttpServletResponse) 
response).encodeURL(url); 
} 
//… 
} 
51
Elastic Resilient 
Copyright 
© 
2014, 
Oracle 
and/or 
its 
affiliates. 
All 
rights 
reserved. 
| 
Reactive 
Programming 
52 
Responsive 
Message 
Driven 
image 
credit: 
reactivemanifesto.org
Servlet 
4.0 
and 
Reactive 
Programming 
Copyright 
© 
2014, 
Oracle 
and/or 
its 
affiliates. 
All 
rights 
reserved. 
| 
• Asynchronous 
in 
Servlet 
3.0 
– ServletRequest#startAsync 
– AsyncContext 
• #addListener, 
#dispatch, 
#complete 
– AsyncListener 
• #onComplete, 
#onError, 
#onStartAsync, 
#onTimeout 
• Event-­‐driven 
– Server-­‐Sent 
Events 
53
Servlet 
4.0 
and 
Reactive 
Programming 
Copyright 
© 
2014, 
Oracle 
and/or 
its 
affiliates. 
All 
rights 
reserved. 
| 
• Non-­‐blocking 
IO 
in 
Servlet 
3.1 
– ServletInputStream 
• #setReadListener, 
#isReady 
– ServletOutputStream 
• #setWriteListener, 
#isReady 
– ReadListener 
• #onDataAvailable, 
#onAllDataRead, 
#onError 
– WriteListener 
• #onWritePossible, 
#onError 
54
Copyright 
© 
2014, 
Oracle 
and/or 
its 
affiliates. 
All 
rights 
reserved. 
| 
Agenda 
Java 
EE 
8 
Why 
HTTP/2? 
HTTP/2 
Big 
Features 
How 
Servlet 
Might 
Expose 
These 
Features 
Java 
SE 
9 
Support 
for 
HTTP/2 
Summary 
and 
Current 
Status 
55
Java 
SE 
9 
Support 
for 
HTTP/2 
• JEP 
Copyright 
© 
2014, 
Oracle 
and/or 
its 
affiliates. 
All 
rights 
reserved. 
| 
110 
- http://openjdk.java.net/jeps/110 
• Easy 
to 
use 
API 
• Covers 
only 
the 
most 
common 
use 
cases 
• Supports 
both 
HTTP 
1.1 
and 
2 
56
Java 
SE 
9 
Support 
for 
HTTP/2 
Copyright 
© 
2014, 
Oracle 
and/or 
its 
affiliates. 
All 
rights 
reserved. 
| 
Small 
footprint 
• Two 
classes 
(working 
titles) 
– HttpRequestGroup 
• configuration 
for 
multiple 
requests 
– HttpRequest 
• one 
request/response 
interaction 
57
Java 
SE 
9 
Support 
for 
HTTP/2 
Copyright 
© 
2014, 
Oracle 
and/or 
its 
affiliates. 
All 
rights 
reserved. 
| 
Small 
footprint 
• Blocking 
mode: 
one 
thread 
per 
request/response 
– send 
request 
– get 
response 
• Non-­‐blocking 
mode: 
handle 
multiple 
request/response 
interactions 
in 
single 
thread 
using 
non-­‐blocking 
API 
– analogous 
to 
NIO 
selectors 
58
Java 
SE 
9 
Support 
for 
HTTP/2 
Copyright 
© 
2014, 
Oracle 
and/or 
its 
affiliates. 
All 
rights 
reserved. 
| 
• Responses 
handled 
through 
lambda 
style 
callback 
handlers 
– Invoked 
on 
the 
calling 
thread 
– Must 
allocate 
threads 
to 
responses 
manually 
• Request/Response 
bodies 
handled 
as 
InputStream/OutputStream 
Callback 
handlers 
59
Java 
SE 
9 
Support 
for 
HTTP/2 
HttpRequestGroup 
group 
= 
HttpRequestGroup.create(); 
HttpRequest 
req 
= 
group.createRequest() 
Copyright 
© 
2014, 
Oracle 
and/or 
its 
affiliates. 
All 
rights 
reserved. 
| 
.setRequestMethod("POST") 
.setRequestURI(new 
URI("http://www.foo.com/a/b") 
.setRequestBody("Param1=1,Param2=2") 
.onResponseHeader("X-­‐Foo", 
(request, 
name, 
value) 
-­‐> 
{ 
System.out.printf(" 
received 
an 
X-­‐Foo 
header"); 
}) 
.sendRequest() 
.waitForCompletion(); 
60
Java 
SE 
9 
Support 
for 
HTTP/2 
HttpRequestGroup 
group 
= 
HttpRequestGroup.create(); 
HttpRequest 
req 
= 
group.createRequest() 
… 
.onResponseBody((HttpRequest 
request, 
InputStream 
in) 
-­‐> 
{ 
if 
(request.getResponseCode() 
== 
200) 
{ 
Path 
out 
= 
Paths.get("/tmp/out"); 
try 
{ 
Files.copy(in, 
out); 
} 
finally 
{ 
in.close(); 
} 
} 
Copyright 
© 
2014, 
Oracle 
and/or 
its 
affiliates. 
All 
rights 
reserved. 
| 
}) 
.sendRequest() 
.waitForCompletion(); 
61
Copyright 
© 
2014, 
Oracle 
and/or 
its 
affiliates. 
All 
rights 
reserved. 
| 
Agenda 
Java 
EE 
8 
Why 
HTTP/2? 
HTTP/2 
Big 
Features 
How 
Servlet 
Might 
Expose 
These 
Features 
Java 
SE 
9 
Support 
for 
HTTP/2 
Summary 
and 
Current 
Status 
62
Summary 
and 
Current 
Status 
• Dec 
2014 
Submit 
HTTP/2 
to 
IESG 
for 
consideration 
as 
a 
Proposed 
Standard 
Copyright 
© 
2014, 
Oracle 
and/or 
its 
affiliates. 
All 
rights 
reserved. 
| 
• Jan 
2015 
Submit 
HTTP/2 
to 
RFC 
Editor 
• Feb 
2015 
Publish 
HTTP/2 
as 
an 
RFC 
63
Summary 
and 
Current 
Status 
• Servlet 
4.0 
brings 
HTTP/2 
to 
Java 
EE 
Copyright 
© 
2014, 
Oracle 
and/or 
its 
affiliates. 
All 
rights 
reserved. 
| 
– 100% 
compliant 
implementation 
of 
HTTP/2 
– Expose 
key 
features 
to 
the 
API 
• Server 
Push 
• Stream 
Prioritization 
• HTTP 
1.1 
upgrade 
64
Summary 
and 
Current 
Status 
• Tentative 
Copyright 
© 
2014, 
Oracle 
and/or 
its 
affiliates. 
All 
rights 
reserved. 
| 
Delivery 
Schedule 
– Q3 
2014: 
JSR 
369 
Expert 
Group 
formed 
– Q1 
2015: 
early 
draft 
– Q3 
2015: 
public 
review 
– Q4 
2015: 
proposed 
final 
draft 
– Q3 
2016: 
final 
release 
• Contribute! 
65
Copyright 
© 
2014, 
Oracle 
and/or 
its 
affiliates. 
All 
rights 
reserved. 
How 
to 
Get 
Involved 
• Join 
an 
Expert 
Group 
project 
– http://javaee-­‐spec.java.net 
• Adopt 
a 
JSR 
– http://glassfish.org/adoptajsr 
• The 
Aquarium 
– http://blogs.oracle.com/theaquarium 
• Java 
EE 
8 
Reference 
Implementation 
– http://glassfish.org 
66
Copyright 
© 
2014, 
Oracle 
and/or 
its 
affiliates. 
All 
rights 
reserved. 
Resources 
• https://java.net/projects/servlet-­‐spec/ 
• https://jcp.org/en/jsr/detail?id=369 
• http://openjdk.java.net/jeps/110 
• http://http2.github.io 
• http://chimera.labs.oreilly.com/books/1230000000545/ch12.html 
67
Copyright 
© 
2014, 
Oracle 
and/or 
its 
affiliates. 
All 
rights 
reserved. 
| 
68
HTTP/2 Comes to Java - What Servlet 4.0 Means to You
1 of 69

Recommended

If You Think You Can Stay Away from Functional Programming, You Are Wrong by
If You Think You Can Stay Away from Functional Programming, You Are WrongIf You Think You Can Stay Away from Functional Programming, You Are Wrong
If You Think You Can Stay Away from Functional Programming, You Are WrongMario Fusco
7.4K views44 slides
Monadic Java by
Monadic JavaMonadic Java
Monadic JavaMario Fusco
65.9K views73 slides
Trees In The Database - Advanced data structures by
Trees In The Database - Advanced data structuresTrees In The Database - Advanced data structures
Trees In The Database - Advanced data structuresLorenzo Alberton
144.6K views128 slides
A Scala Corrections Library by
A Scala Corrections LibraryA Scala Corrections Library
A Scala Corrections LibraryPaul Phillips
33K views47 slides
Partizip perfekt by
Partizip perfektPartizip perfekt
Partizip perfektAman Goel
3.1K views3 slides
C++ shared libraries and loading by
C++ shared libraries and loadingC++ shared libraries and loading
C++ shared libraries and loadingRahul Jamwal
171 views15 slides

More Related Content

What's hot

Implementing the IO Monad in Scala by
Implementing the IO Monad in ScalaImplementing the IO Monad in Scala
Implementing the IO Monad in ScalaHermann Hueck
1.3K views88 slides
Präpositionen mit Genitiv - Theorie und Beispiele by
Präpositionen mit Genitiv - Theorie und BeispielePräpositionen mit Genitiv - Theorie und Beispiele
Präpositionen mit Genitiv - Theorie und BeispieleMaria Vaz König
2.8K views45 slides
Predicate Logic by
Predicate LogicPredicate Logic
Predicate Logicgiki67
42.1K views71 slides
Effective Modern C++ by
Effective Modern C++Effective Modern C++
Effective Modern C++Wang Hsiangkai
1.7K views88 slides
Relativpronomen by
RelativpronomenRelativpronomen
RelativpronomenMaria Trullàs Soler
3.7K views13 slides
non-strict functions, bottom and scala by-name parameters by
non-strict functions, bottom and scala by-name parametersnon-strict functions, bottom and scala by-name parameters
non-strict functions, bottom and scala by-name parametersPhilip Schwarz
1.2K views30 slides

What's hot(20)

Implementing the IO Monad in Scala by Hermann Hueck
Implementing the IO Monad in ScalaImplementing the IO Monad in Scala
Implementing the IO Monad in Scala
Hermann Hueck1.3K views
Präpositionen mit Genitiv - Theorie und Beispiele by Maria Vaz König
Präpositionen mit Genitiv - Theorie und BeispielePräpositionen mit Genitiv - Theorie und Beispiele
Präpositionen mit Genitiv - Theorie und Beispiele
Maria Vaz König2.8K views
Predicate Logic by giki67
Predicate LogicPredicate Logic
Predicate Logic
giki6742.1K views
non-strict functions, bottom and scala by-name parameters by Philip Schwarz
non-strict functions, bottom and scala by-name parametersnon-strict functions, bottom and scala by-name parameters
non-strict functions, bottom and scala by-name parameters
Philip Schwarz1.2K views
Type Classes in Scala and Haskell by Hermann Hueck
Type Classes in Scala and HaskellType Classes in Scala and Haskell
Type Classes in Scala and Haskell
Hermann Hueck1.4K views
Computer Graphics in Java and Scala - Part 1 by Philip Schwarz
Computer Graphics in Java and Scala - Part 1Computer Graphics in Java and Scala - Part 1
Computer Graphics in Java and Scala - Part 1
Philip Schwarz403 views
LanguageStore - Adjektive als Nomen by LanguageStore
LanguageStore - Adjektive als NomenLanguageStore - Adjektive als Nomen
LanguageStore - Adjektive als Nomen
LanguageStore7.5K views
ClojurianからみたElixir by Kent Ohashi
ClojurianからみたElixirClojurianからみたElixir
ClojurianからみたElixir
Kent Ohashi2.3K views
Functional Error Handling with Cats by Mark Canlas
Functional Error Handling with CatsFunctional Error Handling with Cats
Functional Error Handling with Cats
Mark Canlas485 views
Ad hoc Polymorphism using Type Classes and Cats by Philip Schwarz
Ad hoc Polymorphism using Type Classes and CatsAd hoc Polymorphism using Type Classes and Cats
Ad hoc Polymorphism using Type Classes and Cats
Philip Schwarz1.5K views
淺談編譯器最佳化技術 by Kito Cheng
淺談編譯器最佳化技術淺談編譯器最佳化技術
淺談編譯器最佳化技術
Kito Cheng11.1K views
WOHIN? Teil 1: in DIE, in DEN, INS + Orte - AKKUSATIV - Menschen A1 - Lek. 8 by Maria Vaz König
WOHIN? Teil 1:  in DIE, in DEN, INS + Orte - AKKUSATIV -  Menschen A1 - Lek. 8WOHIN? Teil 1:  in DIE, in DEN, INS + Orte - AKKUSATIV -  Menschen A1 - Lek. 8
WOHIN? Teil 1: in DIE, in DEN, INS + Orte - AKKUSATIV - Menschen A1 - Lek. 8
Maria Vaz König7K views
Dry-validation update. Dry-validation vs Dry-schema 1.0 - Aleksandra Stolyar ... by Ruby Meditation
Dry-validation update. Dry-validation vs Dry-schema 1.0 - Aleksandra Stolyar ...Dry-validation update. Dry-validation vs Dry-schema 1.0 - Aleksandra Stolyar ...
Dry-validation update. Dry-validation vs Dry-schema 1.0 - Aleksandra Stolyar ...
Ruby Meditation1.6K views

Similar to HTTP/2 Comes to Java - What Servlet 4.0 Means to You

CON5898 What Servlet 4.0 Means To You by
CON5898 What Servlet 4.0 Means To YouCON5898 What Servlet 4.0 Means To You
CON5898 What Servlet 4.0 Means To YouEdward Burns
31.5K views51 slides
2015 UJUG, Servlet 4.0 portion by
2015 UJUG, Servlet 4.0 portion2015 UJUG, Servlet 4.0 portion
2015 UJUG, Servlet 4.0 portionmnriem
994 views37 slides
Servlet 4.0 Adopt-a-JSR 10 Minute Infodeck by
Servlet 4.0 Adopt-a-JSR 10 Minute InfodeckServlet 4.0 Adopt-a-JSR 10 Minute Infodeck
Servlet 4.0 Adopt-a-JSR 10 Minute InfodeckEdward Burns
3.1K views24 slides
HTTP/2 Comes to Java by
HTTP/2 Comes to JavaHTTP/2 Comes to Java
HTTP/2 Comes to JavaDavid Delabassee
2.9K views56 slides
HTTP/2 in the Java Platform -- Java Champions call February 2016 by
HTTP/2 in the Java Platform -- Java Champions call February 2016HTTP/2 in the Java Platform -- Java Champions call February 2016
HTTP/2 in the Java Platform -- Java Champions call February 2016Ed Burns
1.2K views33 slides
Servlet 4.0 at GeekOut 2015 by
Servlet 4.0 at GeekOut 2015Servlet 4.0 at GeekOut 2015
Servlet 4.0 at GeekOut 2015Edward Burns
19.3K views87 slides

Similar to HTTP/2 Comes to Java - What Servlet 4.0 Means to You(20)

CON5898 What Servlet 4.0 Means To You by Edward Burns
CON5898 What Servlet 4.0 Means To YouCON5898 What Servlet 4.0 Means To You
CON5898 What Servlet 4.0 Means To You
Edward Burns31.5K views
2015 UJUG, Servlet 4.0 portion by mnriem
2015 UJUG, Servlet 4.0 portion2015 UJUG, Servlet 4.0 portion
2015 UJUG, Servlet 4.0 portion
mnriem994 views
Servlet 4.0 Adopt-a-JSR 10 Minute Infodeck by Edward Burns
Servlet 4.0 Adopt-a-JSR 10 Minute InfodeckServlet 4.0 Adopt-a-JSR 10 Minute Infodeck
Servlet 4.0 Adopt-a-JSR 10 Minute Infodeck
Edward Burns3.1K views
HTTP/2 in the Java Platform -- Java Champions call February 2016 by Ed Burns
HTTP/2 in the Java Platform -- Java Champions call February 2016HTTP/2 in the Java Platform -- Java Champions call February 2016
HTTP/2 in the Java Platform -- Java Champions call February 2016
Ed Burns1.2K views
Servlet 4.0 at GeekOut 2015 by Edward Burns
Servlet 4.0 at GeekOut 2015Servlet 4.0 at GeekOut 2015
Servlet 4.0 at GeekOut 2015
Edward Burns19.3K views
WebSockets in Enterprise Applications by Pavel Bucek
WebSockets in Enterprise ApplicationsWebSockets in Enterprise Applications
WebSockets in Enterprise Applications
Pavel Bucek8K views
HTTP/2 comes to Java. What Servlet 4.0 means to you. DevNexus 2015 by Edward Burns
HTTP/2 comes to Java.  What Servlet 4.0 means to you. DevNexus 2015HTTP/2 comes to Java.  What Servlet 4.0 means to you. DevNexus 2015
HTTP/2 comes to Java. What Servlet 4.0 means to you. DevNexus 2015
Edward Burns19.2K views
Oracle REST Data Services by Chris Muir
Oracle REST Data ServicesOracle REST Data Services
Oracle REST Data Services
Chris Muir3.8K views
What's next for Java API for WebSocket (JSR 356) by Pavel Bucek
What's next for Java API for WebSocket (JSR 356)What's next for Java API for WebSocket (JSR 356)
What's next for Java API for WebSocket (JSR 356)
Pavel Bucek34.1K views
Oracle REST Data Services Best Practices/ Overview by Kris Rice
Oracle REST Data Services Best Practices/ OverviewOracle REST Data Services Best Practices/ Overview
Oracle REST Data Services Best Practices/ Overview
Kris Rice16.4K views
JavaOne 2014 Java EE 8 Booth Slides by Edward Burns
JavaOne 2014 Java EE 8 Booth SlidesJavaOne 2014 Java EE 8 Booth Slides
JavaOne 2014 Java EE 8 Booth Slides
Edward Burns1.1K views
Using MySQL Enterprise Monitor for Continuous Performance Improvement by Mark Matthews
Using MySQL Enterprise Monitor for Continuous Performance ImprovementUsing MySQL Enterprise Monitor for Continuous Performance Improvement
Using MySQL Enterprise Monitor for Continuous Performance Improvement
Mark Matthews731 views
WebRTC with Java by amithap07
WebRTC with JavaWebRTC with Java
WebRTC with Java
amithap0716.7K views
WebSocket in Enterprise Applications 2015 by Pavel Bucek
WebSocket in Enterprise Applications 2015WebSocket in Enterprise Applications 2015
WebSocket in Enterprise Applications 2015
Pavel Bucek1.9K views
Oracle Warehouse Builder to Oracle Data Integrator 12c Migration Utility by Noel Sidebotham
Oracle Warehouse Builder to Oracle Data Integrator 12c Migration UtilityOracle Warehouse Builder to Oracle Data Integrator 12c Migration Utility
Oracle Warehouse Builder to Oracle Data Integrator 12c Migration Utility
Noel Sidebotham2.5K views
WebLogic 12c - OMF Canberra June 2014 by Joelith
WebLogic 12c - OMF Canberra June 2014WebLogic 12c - OMF Canberra June 2014
WebLogic 12c - OMF Canberra June 2014
Joelith809 views

More from David Delabassee

JVMs in Containers - Best Practices by
JVMs in Containers - Best PracticesJVMs in Containers - Best Practices
JVMs in Containers - Best PracticesDavid Delabassee
726 views37 slides
JVMs in Containers by
JVMs in ContainersJVMs in Containers
JVMs in ContainersDavid Delabassee
1.3K views38 slides
Serverless Java Challenges & Triumphs by
Serverless Java Challenges & TriumphsServerless Java Challenges & Triumphs
Serverless Java Challenges & TriumphsDavid Delabassee
1.2K views46 slides
Serverless Java - Challenges and Triumphs by
Serverless Java - Challenges and TriumphsServerless Java - Challenges and Triumphs
Serverless Java - Challenges and TriumphsDavid Delabassee
282 views41 slides
Randstad Docker meetup - Serverless by
Randstad Docker meetup - ServerlessRandstad Docker meetup - Serverless
Randstad Docker meetup - ServerlessDavid Delabassee
322 views37 slides
Java Serverless in Action - Voxxed Banff by
Java Serverless in Action - Voxxed BanffJava Serverless in Action - Voxxed Banff
Java Serverless in Action - Voxxed BanffDavid Delabassee
232 views22 slides

More from David Delabassee(20)

Serverless Java Challenges & Triumphs by David Delabassee
Serverless Java Challenges & TriumphsServerless Java Challenges & Triumphs
Serverless Java Challenges & Triumphs
David Delabassee1.2K views
Serverless Java - Challenges and Triumphs by David Delabassee
Serverless Java - Challenges and TriumphsServerless Java - Challenges and Triumphs
Serverless Java - Challenges and Triumphs
David Delabassee282 views
Java Serverless in Action - Voxxed Banff by David Delabassee
Java Serverless in Action - Voxxed BanffJava Serverless in Action - Voxxed Banff
Java Serverless in Action - Voxxed Banff
David Delabassee232 views
Java EE Next - BeJUG JavaOne Afterglow 2016 by David Delabassee
Java EE Next - BeJUG JavaOne Afterglow 2016Java EE Next - BeJUG JavaOne Afterglow 2016
Java EE Next - BeJUG JavaOne Afterglow 2016
David Delabassee433 views
HTTP/2 comes to Java (Dec. 2015 version) by David Delabassee
HTTP/2 comes to Java (Dec. 2015 version)HTTP/2 comes to Java (Dec. 2015 version)
HTTP/2 comes to Java (Dec. 2015 version)
David Delabassee690 views
EJB and CDI - Alignment and Strategy by David Delabassee
EJB and CDI - Alignment and StrategyEJB and CDI - Alignment and Strategy
EJB and CDI - Alignment and Strategy
David Delabassee31.9K views
Java EE 8 - What’s new on the Web front by David Delabassee
Java EE 8 - What’s new on the Web frontJava EE 8 - What’s new on the Web front
Java EE 8 - What’s new on the Web front
David Delabassee960 views
Java EE 8 Adopt a JSR : JSON-P 1.1 & MVC 1.0 by David Delabassee
Java EE 8 Adopt a JSR : JSON-P 1.1 & MVC 1.0Java EE 8 Adopt a JSR : JSON-P 1.1 & MVC 1.0
Java EE 8 Adopt a JSR : JSON-P 1.1 & MVC 1.0
David Delabassee1.8K views

Recently uploaded

PRODUCT PRESENTATION.pptx by
PRODUCT PRESENTATION.pptxPRODUCT PRESENTATION.pptx
PRODUCT PRESENTATION.pptxangelicacueva6
18 views1 slide
GDSC CTU First Meeting Party by
GDSC CTU First Meeting PartyGDSC CTU First Meeting Party
GDSC CTU First Meeting PartyNational Yang Ming Chiao Tung University
11 views25 slides
Melek BEN MAHMOUD.pdf by
Melek BEN MAHMOUD.pdfMelek BEN MAHMOUD.pdf
Melek BEN MAHMOUD.pdfMelekBenMahmoud
17 views1 slide
Ransomware is Knocking your Door_Final.pdf by
Ransomware is Knocking your Door_Final.pdfRansomware is Knocking your Door_Final.pdf
Ransomware is Knocking your Door_Final.pdfSecurity Bootcamp
66 views46 slides
Zero to Automated in Under a Year by
Zero to Automated in Under a YearZero to Automated in Under a Year
Zero to Automated in Under a YearNetwork Automation Forum
22 views23 slides
SAP Automation Using Bar Code and FIORI.pdf by
SAP Automation Using Bar Code and FIORI.pdfSAP Automation Using Bar Code and FIORI.pdf
SAP Automation Using Bar Code and FIORI.pdfVirendra Rai, PMP
25 views38 slides

Recently uploaded(20)

SAP Automation Using Bar Code and FIORI.pdf by Virendra Rai, PMP
SAP Automation Using Bar Code and FIORI.pdfSAP Automation Using Bar Code and FIORI.pdf
SAP Automation Using Bar Code and FIORI.pdf
Special_edition_innovator_2023.pdf by WillDavies22
Special_edition_innovator_2023.pdfSpecial_edition_innovator_2023.pdf
Special_edition_innovator_2023.pdf
WillDavies2218 views
GDG Cloud Southlake 28 Brad Taylor and Shawn Augenstein Old Problems in the N... by James Anderson
GDG Cloud Southlake 28 Brad Taylor and Shawn Augenstein Old Problems in the N...GDG Cloud Southlake 28 Brad Taylor and Shawn Augenstein Old Problems in the N...
GDG Cloud Southlake 28 Brad Taylor and Shawn Augenstein Old Problems in the N...
James Anderson126 views
Data Integrity for Banking and Financial Services by Precisely
Data Integrity for Banking and Financial ServicesData Integrity for Banking and Financial Services
Data Integrity for Banking and Financial Services
Precisely29 views
"Node.js Development in 2024: trends and tools", Nikita Galkin by Fwdays
"Node.js Development in 2024: trends and tools", Nikita Galkin "Node.js Development in 2024: trends and tools", Nikita Galkin
"Node.js Development in 2024: trends and tools", Nikita Galkin
Fwdays17 views
Future of AR - Facebook Presentation by ssuserb54b561
Future of AR - Facebook PresentationFuture of AR - Facebook Presentation
Future of AR - Facebook Presentation
ssuserb54b56122 views
STKI Israeli Market Study 2023 corrected forecast 2023_24 v3.pdf by Dr. Jimmy Schwarzkopf
STKI Israeli Market Study 2023   corrected forecast 2023_24 v3.pdfSTKI Israeli Market Study 2023   corrected forecast 2023_24 v3.pdf
STKI Israeli Market Study 2023 corrected forecast 2023_24 v3.pdf
2024: A Travel Odyssey The Role of Generative AI in the Tourism Universe by Simone Puorto
2024: A Travel Odyssey The Role of Generative AI in the Tourism Universe2024: A Travel Odyssey The Role of Generative AI in the Tourism Universe
2024: A Travel Odyssey The Role of Generative AI in the Tourism Universe
Simone Puorto13 views
STPI OctaNE CoE Brochure.pdf by madhurjyapb
STPI OctaNE CoE Brochure.pdfSTPI OctaNE CoE Brochure.pdf
STPI OctaNE CoE Brochure.pdf
madhurjyapb14 views
TrustArc Webinar - Managing Online Tracking Technology Vendors_ A Checklist f... by TrustArc
TrustArc Webinar - Managing Online Tracking Technology Vendors_ A Checklist f...TrustArc Webinar - Managing Online Tracking Technology Vendors_ A Checklist f...
TrustArc Webinar - Managing Online Tracking Technology Vendors_ A Checklist f...
TrustArc72 views

HTTP/2 Comes to Java - What Servlet 4.0 Means to You

  • 1. HTTP/2 Comes to Java What Servlet 4.0 Means to You JAZOON 2014 David Delabassee (@delabassee) Oracle Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |
  • 2. Safe Harbor Statement 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. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | 2
  • 3. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Agenda Java EE 8 Why HTTP/2? HTTP/2 Big Features How Servlet Might Expose These Features Java SE 9 Support for HTTP/2 Summary and Current Status 3
  • 4. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Agenda Java EE 8 Why HTTP/2? HTTP/2 Big Features How Servlet Might Expose These Features Java SE 9 Support for HTTP/2 Summary and Current Status 4
  • 5. DEVELOPER PRODUCTIVITY Copyright © 2014, Oracle and/or its affiliates. All rights reserved. Java EE 7 ENTERPRISE EDITION ▪Batch ▪Concurrency ▪Simplified JMS ▪More annotated POJOs ▪Less boilerplate code ▪Cohesive integrated platform ▪WebSockets ▪JSON ▪Servlet 3.1 NIO ▪REST MEETING ENTERPRISE DEMANDS Java EE 7 5
  • 6. Industry Trends We're Seeing Reactive Programming Copyright © 2014, Oracle and/or its affiliates. All rights reserved. Cloud Mobile HTTP/2 SECURITY User Experience 6
  • 7. Java EE 8 Community Survey Copyright © 2014, Oracle and/or its affiliates. All rights reserved. • 3 parts over 3½ months – 47 questions – 15 fill-­‐ins – 1000’s of comments • 4500+ respondents • Prioritization of most-­‐popular features 7
  • 8. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.
  • 9. Community-­‐Prioritized Features Copyright © 2014, Oracle and/or its affiliates. All rights reserved. 9
  • 10. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. Java EE 8 Themes • HTML5 / Web Tier Enhancements • Infrastructure for running in the Cloud • Ease of Development / CDI alignment 10
  • 11. Ease of Development / CDI Alignment Copyright © 2014, Oracle and/or its affiliates. All rights reserved. • Security interceptors • Simplified messaging through CDI-­‐based “MDBs” • JAX-­‐RS injection alignment • WebSocket scopes • Pruning of EJB 2.x client view and IIOP interoperability 11
  • 12. Modernize the Infrastructure For On-­‐Premise and for in the Cloud Copyright © 2014, Oracle and/or its affiliates. All rights reserved. • Java EE Management 2.0 – REST-­‐based APIs for Management and Deployment • Java EE Security 1.0 – Authorization – Password Aliasing – User Management – Role Mapping – Authentication – REST Authentication 12
  • 13. HTML5 Support / Web Tier Enhancements Copyright © 2014, Oracle and/or its affiliates. All rights reserved. • JSON Binding • JSON Processing enhancements • Server-­‐sent events • Action-­‐based MVC • HTTP/2 support 13
  • 14. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. Java EE 8 JSRs • Java EE 8 Platform • CDI 2.0 • JSON Binding 1.0 • JAX-­‐RS 2.1 • MVC 1.0 • Java Servlet 4.0 • JSF 2.3 • JMS 2.1 • JSON-­‐P 1.1 • Java EE Security 1.0 • Java EE Management 2.0 • … and more to follow … So far….. Coming soon ….. 14
  • 15. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Agenda Java EE 8 Why HTTP/2? HTTP/2 Big Features How Servlet Might Expose These Features Java SE 9 Support for HTTP/2 Summary and Current Status 15
  • 16. . . . Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | A Real Life Example index.html style1.css style2.css script1.js . . . script9.js pic1.jpg pic8.jpg photo1.png photo2.png . . .
  • 17. Client Server Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Problems in HTTP 1.1 • HTTP Pipelining • Head-­‐of-­‐Line blocking index.html style1.css style2.css index.html style1.css style2.css script1.js script2.js . . . script1.js script2.js . . .
  • 18. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | • Inefficient use of TCP sockets Client Server Client Server Client Server Client Server Client Server Client Server Problems in HTTP 1.1
  • 19. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | At the beginning… 19 <img/>
  • 20. File Concatenation and Image Sprites TCP Efficiency Improves with Larger Files Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | 20 • Modern web page now consists of more than 90 resources fetched from 15 distinct hosts - http://httparchive.org • Solution – Shoving more than one logical file into one physical file
  • 21. File Concatenation and Image Sprites TCP Efficiency Improves with Larger Files Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | 21 .ic-­‐AerospaceAndDefense-­‐wht-­‐on-­‐gray, .ic-­‐AerospaceAndDefense-­‐wht-­‐on-­‐red, .ic-­‐ Airline-­‐wht-­‐on-­‐gray, .ic-­‐Airline-­‐wht-­‐on-­‐red{ background: url(sprites.png) no-­‐repeat; } .ic-­‐AerospaceAndDefense-­‐wht-­‐on-­‐gray{ background-­‐position: 0 0; width: 80px; height: 80px; } .ic-­‐AerospaceAndDefense-­‐wht-­‐on-­‐red{ background-­‐position: -­‐81px 0; width: 80px; height: 80px; } .ic-­‐Airline-­‐wht-­‐on-­‐gray{ background-­‐position: 0 -­‐80px ; width: 80px; height: 80px; } .ic-­‐Airline-­‐wht-­‐on-­‐red{ background-­‐position: -­‐81px -­‐79px ; width: 80px; height: 80px; }
  • 22. File Concatenation and Image Sprites TCP Efficiency Improves with Larger Files Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | 22
  • 23. Domain Sharding Split page resources across several hosts to work around browser limits Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | 23
  • 24. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Inlined Assets Base64 Encoding Will Never Die • data URLs • <img src="data:image/gif;base64,R0lGODlhEAAOALMAAOazToeHh0tLS/ 7LZv0jvb29tf3Ubge8WSLrhf3kdbW1mxsbPmfyH5BAAAjAAAALAAfhGHhcjA AAAQAA4lsjkhfkjfhGHhcjGDSHJUYgJvhgtyrHgfGfHyt56HGfGH56ge8WSLf6G GHvvhdsbxusbaOiQA4lsjkhfkjf4lsjkhfkjf4lsjkhfkjfhfkjfhpBREzxvt6QAA4lsjkhf kjfhdxwqBnuIoYtyGhBKoOjJj6GGHvvhdsbxus38GV3DcPjjBceXsplojj…” /> 24
  • 25. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | • HTTP uses TCP poorly - HTTP flows are short and bursty - TCP was built for long-­‐lived flows • Solutions – Sprites – Domain sharding – Assets Inlining – File concatenations – … 25 HTTP 1.1 circa 1999 Problems Vs Solutions
  • 26. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | • “Conversion Rate” Vs Latency - 1 in 4 people abandons surfing to a site if the page takes longer than 4 seconds to loads - Page load slowdown of 1 second could cost Amazon $1.6 billion in sales each year - Slowing search results by just 4/10 of a second, Google could lose 8 million searches per day - http://www.fastcompany.com/1825005/how-­‐one-­‐second-­‐could-­‐cost-­‐amazon-­‐16-­‐ billion-­‐sales 26 Time is Money!
  • 27. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | google.fr (1st) • 3 HTTP Requests • 21.355 bytes - 1 HTML - 1 image - 1 ? 27 Top .FR examples lefigaro.fr (15th) • 140 HTTP Requests • 2.736.562 bytes - 1 HTML - 130 images - 6 .js - 2 .css - 1 ?
  • 28. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Agenda Java EE 8 Why HTTP/2? HTTP/2 Big Features How Servlet Might Expose These Features Java SE 9 Support for HTTP/2 Summary and Current Status 28
  • 29. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | 29 HTTP/2 Big Ticket Features Review • Binary Framing • Request/Response multiplexing • Stream Prioritization • Server Push • Header Compression • Upgrade from HTTP 1.1 - ALPN (or NPN) - 101 Switching Protocols
  • 30. HTTP/2 Request Response Multiplexing Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | • Fully bi-­‐directional – Connection A TCP socket – Stream A “channel” within a connection – Message A logical message, such as a request or a response – Frame The smallest unit of communication in HTTP/2 30 Lets you do more things with a single TCP connection
  • 31. HTTP/2 Request Response Multiplexing Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | 31 Connections, Streams, Messages, Frames
  • 32. HTTP/2 Request Response Multiplexing Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | • Communication broken into frames • Logical streams can be interweaved over a single TCP connection 32 Connections, Streams, Messages, Frames
  • 33. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | HTTP/2 Binary Framing • Frame Header ! • Types - HEADERS, DATA, PRIORITY, RST_STREAM, SETTINGS, PUSH_PROMISE, PING, GOAWAY, WINDOW_UPDATE, CONTINUATION 33 Enabled by dumping newline delimited ASCII Length (24) Type (8) Flags (8) R Stream Identifier (31) Frame Payload (0 …)
  • 34. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | HTTP/2 Binary Framing GET /index.html HTTP/1.1 Host: example.com Accept: text/html 34 Example 1 HEADERS + END_STREAM + END_HEADERS :method: GET :scheme: http :path: /index.html :authority: example.org accept: text/html
  • 35. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | HTTP/2 Binary Framing HTTP/1.1 200 OK Content-­‐Length: 11 Content-­‐Type: text/html Hello World 35 Example 2 HEADERS -­‐ END_STREAM + END_HEADERS :status: 200 content-­‐length: 11 content-­‐type: text/html DATA + END_STREAM Hello World
  • 36. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | HTTP/2 Stream Prioritization • Stream Dependency in HEADERS Frame • PRIORITY frame type • An additional 40 bytes – Stream id (31) –Weight (8): [1, 256] – Exclusive bit (1) • Only an advice 36 A B C 4 12 A B D C 4 16 12 exclusive = 0 A D 16 B C 4 12 exclusive = 1
  • 37. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | HTTP/2 Server Push • Eliminates the need for resource inlining • Lets the server populate the browser’s cache in advance of the browser asking for the resource to put in the cache • No corresponding JavaScript API • Can be combined with SSE – Server pushes stuff into the browser’s cache – Server uses SSE to tell the browser to go fetch it 37
  • 38. HTTP/2 Header Compression Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | • Most of the headers are the same in a given stream – Host: Accept: user-­‐agent: etc. –Why send them every time? • Server and the client keep tables of headers – Send tables references and updates 38 Known as HPACK
  • 39. HTTP/2 Header Compression Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | 39
  • 40. HTTP/2 Upgrade from HTTP 1.1 Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | • Not secure – Port 80 – HTTP 1.1 101 Protocol Switching • Secure – Next Protocol Negotiation (NPN) – Application Layer Protocol Negotiation (ALPN) 40 Secure or not-­‐secure?
  • 41. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Agenda Java EE 8 Why HTTP/2? HTTP/2 Big Features How Servlet Might Expose These Features Java SE 9 Support for HTTP/2 Summary and Current Status 41
  • 42. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Agenda Java EE 8 Why HTTP/2? HTTP/2 Big Features How Servlet Might Expose These Features Java SE 9 Support for HTTP/2 Summary and Current Status 42
  • 43. Servlet 4.0 Big Ticket New Features Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | • API was designed for “One Request == One Response” • HTTP/2 destroys this assumption • It will be challenging to do justice to the new reality of “One Request == One or More Responses” • We must not simply bolt the “One or More Responses” concept onto some convenient part of the existing API 43 Challenges in Exposing HTTP/2 Features in Servlet API
  • 44. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | • Request/Response multiplexing • Binary Framing • Stream Prioritization • Server Push • Header Compression • Upgrade from HTTP 1.1 – ALPN or (NPN) – 101 Switching Protocols 44 Servlet 4.0 Big Ticket New Features
  • 45. Servlet 4.0 Big Ticket New Features Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | • Request/Response Multiplexing • Binary Framing • Stream Prioritization • Server Push • Header Compression • Upgrade from HTTP 1.1 – ALPN or (NPN) – 101 Switching Protocols 45 HTTP/2 Features Potentially Exposed in Servlet API
  • 46. Servlet 4.0 Big Ticket New Features Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | • Add method HttpServletRequest and HttpServletResponse – int getStreamId() 46 HTTP/2 Features Potentially Exposed in Servlet API
  • 47. Servlet 4.0 Big Ticket New Features Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | • Add a new class Priority – boolean exclusive – int streamId – int weight • Add method to HttpServletRequest – Priority getPriority() • Add methods to HttpServletResponse – Priority getPriority() – void setPriority(Priority p) 47 Stream Prioritization
  • 48. Servlet 4.0 Big Ticket New Features Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | • Push resource to client for a given url and headers • May add callback for completion or error of a push • Not a replacement for WebSocket • Really useful for frameworks that build on Servlet, such as JSF 48 Server Push
  • 49. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | 49
  • 50. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Server Push Example of Potential Use from JSF public class FacesServlet implements Servlet { public void service(ServletRequest req, ServletResponse resp) throws IOException, ServletException { //.. HttpServletRequest request = (HttpServletRequest) req; try { ResourceHandler handler = context.getApplication().getResourceHandler(); if (handler.isResourceRequest(context) || request.isPushRequest()) { handler.handleResourceRequest(context); } else { lifecycle.attachWindow(context); lifecycle.execute(context); lifecycle.render(context); } } } 50
  • 51. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Server Push Example of Potential Use from JSF public class ExternalContextImpl extends ExternalContext { //… public String encodeResourceURL(String url) { if (null == url) { String message = MessageUtils.getExceptionMessageString (MessageUtils.NULL_PARAMETERS_ERROR_MESSAGE_ID, "url"); throw new NullPointerException(message); } Map attrs = getResourceAttrs(); ((HttpServletRequest) request).dispatchPushRequest(url, attrs); return ((HttpServletResponse) response).encodeURL(url); } //… } 51
  • 52. Elastic Resilient Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Reactive Programming 52 Responsive Message Driven image credit: reactivemanifesto.org
  • 53. Servlet 4.0 and Reactive Programming Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | • Asynchronous in Servlet 3.0 – ServletRequest#startAsync – AsyncContext • #addListener, #dispatch, #complete – AsyncListener • #onComplete, #onError, #onStartAsync, #onTimeout • Event-­‐driven – Server-­‐Sent Events 53
  • 54. Servlet 4.0 and Reactive Programming Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | • Non-­‐blocking IO in Servlet 3.1 – ServletInputStream • #setReadListener, #isReady – ServletOutputStream • #setWriteListener, #isReady – ReadListener • #onDataAvailable, #onAllDataRead, #onError – WriteListener • #onWritePossible, #onError 54
  • 55. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Agenda Java EE 8 Why HTTP/2? HTTP/2 Big Features How Servlet Might Expose These Features Java SE 9 Support for HTTP/2 Summary and Current Status 55
  • 56. Java SE 9 Support for HTTP/2 • JEP Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | 110 - http://openjdk.java.net/jeps/110 • Easy to use API • Covers only the most common use cases • Supports both HTTP 1.1 and 2 56
  • 57. Java SE 9 Support for HTTP/2 Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Small footprint • Two classes (working titles) – HttpRequestGroup • configuration for multiple requests – HttpRequest • one request/response interaction 57
  • 58. Java SE 9 Support for HTTP/2 Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Small footprint • Blocking mode: one thread per request/response – send request – get response • Non-­‐blocking mode: handle multiple request/response interactions in single thread using non-­‐blocking API – analogous to NIO selectors 58
  • 59. Java SE 9 Support for HTTP/2 Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | • Responses handled through lambda style callback handlers – Invoked on the calling thread – Must allocate threads to responses manually • Request/Response bodies handled as InputStream/OutputStream Callback handlers 59
  • 60. Java SE 9 Support for HTTP/2 HttpRequestGroup group = HttpRequestGroup.create(); HttpRequest req = group.createRequest() Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | .setRequestMethod("POST") .setRequestURI(new URI("http://www.foo.com/a/b") .setRequestBody("Param1=1,Param2=2") .onResponseHeader("X-­‐Foo", (request, name, value) -­‐> { System.out.printf(" received an X-­‐Foo header"); }) .sendRequest() .waitForCompletion(); 60
  • 61. Java SE 9 Support for HTTP/2 HttpRequestGroup group = HttpRequestGroup.create(); HttpRequest req = group.createRequest() … .onResponseBody((HttpRequest request, InputStream in) -­‐> { if (request.getResponseCode() == 200) { Path out = Paths.get("/tmp/out"); try { Files.copy(in, out); } finally { in.close(); } } Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | }) .sendRequest() .waitForCompletion(); 61
  • 62. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Agenda Java EE 8 Why HTTP/2? HTTP/2 Big Features How Servlet Might Expose These Features Java SE 9 Support for HTTP/2 Summary and Current Status 62
  • 63. Summary and Current Status • Dec 2014 Submit HTTP/2 to IESG for consideration as a Proposed Standard Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | • Jan 2015 Submit HTTP/2 to RFC Editor • Feb 2015 Publish HTTP/2 as an RFC 63
  • 64. Summary and Current Status • Servlet 4.0 brings HTTP/2 to Java EE Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | – 100% compliant implementation of HTTP/2 – Expose key features to the API • Server Push • Stream Prioritization • HTTP 1.1 upgrade 64
  • 65. Summary and Current Status • Tentative Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Delivery Schedule – Q3 2014: JSR 369 Expert Group formed – Q1 2015: early draft – Q3 2015: public review – Q4 2015: proposed final draft – Q3 2016: final release • Contribute! 65
  • 66. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. How to Get Involved • Join an Expert Group project – http://javaee-­‐spec.java.net • Adopt a JSR – http://glassfish.org/adoptajsr • The Aquarium – http://blogs.oracle.com/theaquarium • Java EE 8 Reference Implementation – http://glassfish.org 66
  • 67. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. Resources • https://java.net/projects/servlet-­‐spec/ • https://jcp.org/en/jsr/detail?id=369 • http://openjdk.java.net/jeps/110 • http://http2.github.io • http://chimera.labs.oreilly.com/books/1230000000545/ch12.html 67
  • 68. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | 68