24
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | Adopt-a-JSR: JSR-369 Servlet 4.0 Ed Burns and Dr. Shing-Wai Chan Spec Leads for Servlet Java EE Specification Team December, 2014

Servlet 4.0 Adopt-a-JSR 10 Minute Infodeck

Embed Size (px)

Citation preview

Page 1: Servlet 4.0 Adopt-a-JSR 10 Minute Infodeck

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |

Adopt-a-JSR: JSR-369Servlet 4.0

Ed Burns and Dr. Shing-Wai ChanSpec Leads for ServletJava EE Specification TeamDecember, 2014

Page 2: Servlet 4.0 Adopt-a-JSR 10 Minute Infodeck

Copyright © 2015, 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.

Page 3: Servlet 4.0 Adopt-a-JSR 10 Minute Infodeck

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |

• Ed Burns

– Oracle

• Long time user of Servlet technology• Co-spec lead of JSF since 2004

Speaker Credentials

Page 4: Servlet 4.0 Adopt-a-JSR 10 Minute Infodeck

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |

• Ed Burns

– Oracle

• Long time user of Servlet technology• Co-spec lead of JSF since 2004

Speaker Credentials

Page 5: Servlet 4.0 Adopt-a-JSR 10 Minute Infodeck

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |

• Dr. Shing Wai Chan

– Oracle

• Servlet Spec Lead since 2013• Expert group member on many JSRs

relating to Servlet since 2001

Speaker Credentials

Page 6: Servlet 4.0 Adopt-a-JSR 10 Minute Infodeck

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |

Program Agenda

HTTP2 Big Features

How Servlet Might Expose These Features

Adopt-a-JSR

1

2

3

Page 7: Servlet 4.0 Adopt-a-JSR 10 Minute Infodeck

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |

Program Agenda

HTTP2 Big Features

How Servlet Might Expose These Features

Adopt-a-JSR

1

2

3

Page 8: Servlet 4.0 Adopt-a-JSR 10 Minute Infodeck

Copyright © 2015, 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

8

HTTP/2 Big Ticket Feature Review

Page 9: Servlet 4.0 Adopt-a-JSR 10 Minute Infodeck

Copyright © 2015, 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, but can be combined with SSE

– Server pushes stuff into the browser’s cache.

– Server uses SSE to tell the browser to go fetch it (but we know it’s already in the browser’s cache).

9E

Page 10: Servlet 4.0 Adopt-a-JSR 10 Minute Infodeck

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |

HTTP/2 Request Response Multiplexing

• Fully bi-directional

• Enabled by defining some terms

– ConnectionA TCP socket

– StreamA “channel” within a connection

–MessageA logical message, such as a request or a response

– FrameThe smallest unit of communication in HTTP/2.

10

Lets you do more things with a single TCP connection

Page 11: Servlet 4.0 Adopt-a-JSR 10 Minute Infodeck

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |

HTTP/2 Request Response Multiplexing

11

Connections, Streams, Messages, Frames

Page 12: Servlet 4.0 Adopt-a-JSR 10 Minute Infodeck

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |

HTTP/2 Request Response Multiplexing

• Once you break the communication down into frames, you can interweave the logical streams over a single TCP connection.

• Yet another idea from the 1960s is new again.

12

Connections, Streams, Messages, Frames

BrowserServerSingle TCP connection for HTTP 2

STREAM'4'HEADERS'

STREAM'9'HEADERS'

STREAM'7'DATA'

STREAM'7'HEADERS'

STREAM'2'HEADERS'

STREAM'2'DATA'

Page 13: Servlet 4.0 Adopt-a-JSR 10 Minute Infodeck

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |

HTTP/2 Binary Framing

• Solves Head-Of-Line (HOL) blocking problem

• Type field can be DATA, HEADERS, PRIORITY, RST_STREAM, SETTINGS, PUSH_PROMISE, PING, GOAWAY, WINDOW_UPDATE, CONTINUATION

13

Enabled by dumping newline delimited ASCII

Length (24)

Type (8) Flags (8)

R Stream Identifier (31)

Frame Payload (0 …)

Page 14: Servlet 4.0 Adopt-a-JSR 10 Minute Infodeck

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |

Program Agenda

HTTP2 Big Features

How Servlet Might Expose These Features

Adopt-a-JSR

1

2

3

Page 15: Servlet 4.0 Adopt-a-JSR 10 Minute Infodeck

Copyright © 2015, 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

15

HTTP/2 Features

Servlet 4.0 Big Ticket New Features

Page 16: Servlet 4.0 Adopt-a-JSR 10 Minute Infodeck

Copyright © 2015, 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

16

HTTP/2 Features Potentially Exposed in Servlet API

Servlet 4.0 Big Ticket New Features

Page 17: Servlet 4.0 Adopt-a-JSR 10 Minute Infodeck

Copyright © 2015, 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 at all a replacement for WebSocket

• Really useful for frameworks that build on Servlet, such as JSF

17

Server Push

Servlet 4.0 Big Ticket New Features

Page 18: Servlet 4.0 Adopt-a-JSR 10 Minute Infodeck

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 18

Server Push

Servlet 4.0Big TicketNew Features

BrowserServer Thread Aservlet.service()

GET /index.html

Server discovers

browser will need style.css and script.js

request.dispatchPushRequest("style.css")

request.dispatchPushRequest("script.js")

Server Thread Bservlet.service()

synthetic GET /style.css

synthetic GET /script.js

Server Thread Cservlet.service()

style.css

script.js

index.html

Page 19: Servlet 4.0 Adopt-a-JSR 10 Minute Infodeck

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |

Server Push

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);

}}

}

Example of Potential Use from JSF

19

Page 20: Servlet 4.0 Adopt-a-JSR 10 Minute Infodeck

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |

Server Push

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);

}//…

}

Example of Potential Use from JSF

20

Page 21: Servlet 4.0 Adopt-a-JSR 10 Minute Infodeck

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |

Program Agenda

HTTP2 Big Features

How Servlet Might Expose These Features

Adopt-a-JSR

1

2

3

Page 22: Servlet 4.0 Adopt-a-JSR 10 Minute Infodeck

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |

Page 23: Servlet 4.0 Adopt-a-JSR 10 Minute Infodeck

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |

Adopt-a-JSR

• Community Tab on JSR-369 page https://jcp.org/en/egc/view?id=369

– JIRA Components: currently we have none. Come up with a list of components for us!

– Use-cases for session-less applications

– List of references to async and thread safety in the spec and javadoc

– You can think of others!

Page 24: Servlet 4.0 Adopt-a-JSR 10 Minute Infodeck

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |

Safe Harbor Statement

The preceding 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.