Alex Rivera | Logout

Should a web framework be a Filter or a Servlet?

Asked 2011-02-24T20:31:25.747
11

Having a web framework handle requests from single point of entry is a solved problem. However, should that single point of entry be a Filter or a Servlet? Why would a web application developer prefer one over the other? Why would a framework developer prefer one over the other?

Edit
Report

3 Answers

0

A web application developer should not really care if it is a filter or a servlet. The developer should simply care about how the framework makes their development easier.

Now, I would even take this further to say that a Web framework does not even have to be based on the J2EE spec (as per the Play Framework), in which the rules have been entirely re-written to make web applications easier to develop for a Java programmer.

answered 2011-02-24T20:36:03.433
0

A Filter is definitely the best choice. A web framework will run as a web application in an application server. The application server will be better for handling some resources, i.e. images and other static files while the web framework should handle calls to dynamic resources. This is easier to achieve if you create a filter that can forward all requests for static resources to the application server (or another filter).

answered 2011-02-24T23:03:24.997
-1

Check this benchmark. You will find Play!framework (Netty based) + Japid template engine is nearly close to static content hosting (even with concurrent user increased).

answered 2011-06-04T06:48:50.080

Your Answer