Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the equivalent of ruby's rack or python's wsgi for Java?

What's the equivalent of ruby's rack or python's wsgi for Java? and a routing library too.

like image 679
Der Avatar asked Aug 01 '12 03:08

Der


2 Answers

From the Python standard PEP 333:

By contrast, although Java has just as many web application frameworks available, Java's "servlet" API makes it possible for applications written with any Java web application framework to run in any web server that supports the servlet API.

http://www.python.org/dev/peps/pep-0333/#rationale-and-goals

like image 174
Alex W Avatar answered Nov 15 '22 17:11

Alex W


Short answer

The equivalent of ruby's rack or python's wsgi in Java are Servlets.

In depth answer

In Python, WSGI (Web Server Gateway Interface) sits under Python web frameworks like Django, Flask, Bottle.

Servlets are to Java what WSGI is to Python — a common specification for web servers that allows web servers and application frameworks to interact with each other based on a common API.

Java web frameworks, are designed around the front controller pattern in which a central Servlet is the focal point for incoming requests.

It is common that the Servlet component is completely integrated inside the web framework itself so that developers only need to interact with higher level components - for example the DispatcherServlet in the Spring MVC framework.

Regarding routing library in JAVA:
If you're using the Spring framework then routing can be done with the Spring MVC module which is a web application framework and has more capabilities than just simple routing.

If you're working with J2EE then you can use Jersey which is an implementation of the JAX-RS Spec.

like image 20
RtmY Avatar answered Nov 15 '22 18:11

RtmY