Is Java Servlet Filter equivalent to Ruby [on Rails] and PHP?

Not sure if the terminology is correct, but does it have Ruby and PHP equivalents to Java Servlet Filters? Are they specific concrete classes?

I assume there are a number of common web application libraries / frameworks in Python as well. Is there an equivalent?

Thank.

=== ADDITION ===

With good advice from Kevin Davis , I just want to quickly go over what Java Servlet Filters are. It is basically an interceptor for HTTP requests. A filter chain can be configured between the unhandled receipt of the request and the final destination of the request. Request parameters (and cookies, headers, etc., etc.) are passed to the first filter in the chain, and each filter does something with them (or not) and then passes them to the chain (or not). for example, a caching filter might just return the result, bypassing the rest of the chain and endpoint).

One advantage is the ability to change or improve the web application without touching the source code of the endpoint.

Greetings.

+1


source to share


4 answers


I assume there are also a number of common web application libraries / frameworks in Python. Is there an equivalent?



Django provides a framework for intermediate hooks that can be used to modify I / O when processing a request / response. See the middleware documentation page for details .

+2


source


In a typical Apache / PHP scenario , the answer is usually: No, there are no custom filters. However, there are some solutions to the problems solved with Java Servlet Filters:



You can create a .htaccess

file
to set these properties for a directory and its subdirectories.

0


source


Ruby on Rails has filters that serve this purpose

New Rack Middleware feature that is similar to Django middleware

0


source


In the PHP world, Zend Framework provides a plugin API for its front controller object that allows you to wire plugin objects between pre-routing and post-dispatch phases. While I have not had a chance to work with Java Servlets, I am guessing that this will match the description in your appendix. Anyway, it's not built into PHP, its structure depends on RoR or Django.

0


source







All Articles