Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jetty: servlets vs handlers

Tags:

I am trying to understand Jetty.

Tell me please:

  1. When is it better to use Servlets and when Handlers?

  2. Can I use Connectors with Servlets for "thread-per-request model"?

like image 424
Edward83 Avatar asked Nov 12 '10 10:11

Edward83


1 Answers

In Jetty, Handlers handle requests that are coming through Connectors. One of the Handlers, specifically ServletHandler, allows Jetty to (mostly) support servlets. Servlet is a portable Java EE concept, so you can design your application in a more portable way if you use servlets in Jetty. On the other hand, they are likely to bring some overhead, so you might want to implement a Handler directly that would handle requests coming via Connectors.

If you are using servlets in Jetty, you can rely on the servlet security model, on the session support, etc. If this is unnecessary for your application, you might be better off implementing a very simple handler.

like image 95
Olaf Avatar answered Sep 21 '22 18:09

Olaf