62

I've heard something and seen some examples of web application built using ASP.NET / PHP and I'm wondering what would be the equivalent way of doing similar things in Java world. Looking on the Wikipedia I have found a lot of frameworks and I'm kind of confused which one is the best.

Veronika D
  • 1,031
  • 2
  • 11
  • 10

2 Answers2

104

The Java equivalent of PHP and "Classic" ASP would be JSP (JavaServer Pages) with scriptlets (embedded raw Java code). Scriptlets are considered poor practice in Java web development world. Taglibs and EL (Expression Language) should be preferred above scriptlets. The Java equivalent of ASP.NET (MVC) would be a Java MVC framework. There are a lot of Java-based MVC frameworks out, mostly providing a Servlet/Filter-based controller and taglibs to interact with the model (usually a Javabean) and the view (usually a JSP page, but XHTML is also possible).

To start, the Java EE API provides JSF (JavaServer Faces) for this, which in turn comes along with XHTML based templated view technology known as Facelets. Facelets is seen as a replacement of the good old JSP. Further, there are a lot of open source Java MVC frameworks which are built on top of the JSP/Servlet API and which are intended as an alternative/competition to JSF. You can find little information of all of them here, the popular ones being Spring MVC, Struts2 and Stripes.

As to which one to choose, I suggest having a look at this answer which I strongly agree.

Community
  • 1
  • 1
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • 3
    And another +1 for this nice answer. – Pascal Thivent Mar 31 '10 at 23:37
  • @BalusC According to [this question](http://stackoverflow.com/questions/4801891/difference-between-request-mvc-and-component-mvc) it seems that ASP.NET MVC is a request (action) MVC framework, is that correct? (I assume that request/action and component-based are the two unique/main groups of MVC frameworks). BTW I'm also curious about which would be some PHP equivalents to these. – Piovezan Jan 27 '14 at 16:49
  • Please, share some experience on server hardware resources usage with GlassFish and JavaEE, compared to PHP or NodeJS. Java is often claimed to be very wasteful. – Zon Apr 12 '18 at 10:08
6

The best is not necessarily the same as the most mainstream. I think the most direct equivalent (thanks to its standards track nature) is JSF 2.0 & Facelets.

Having said that, there are reasons that the other frameworks exist... it's best to evaluate several and determine which one fits your team's style of development best.

See also this question.

Community
  • 1
  • 1
jsight
  • 27,819
  • 25
  • 107
  • 140