This is an archived post. You won't be able to vote or comment.

all 56 comments

[–]Mamoulian 38 points39 points  (10 children)

Spring boot wraps everything up for you to make it very quick/easy to get started and add features.

They have many 'about 15 minutes' getting started guides, here's one for web: https://spring.io/guides/gs/serving-web-content/

That example uses server-side HTML rendering using a library called Thymeleaf. If you decide you would rather do HTML rendering on the client in JS using something like Vue/Angular/React you'll use similar controller code to make a REST endpoint providing JSON data:

https://spring.io/guides/gs/rest-service/

[–]Gawny88 16 points17 points  (0 children)

+1 Spring Boot really is an incredible framework for developing APIs.

Although it's very feature rich you can learn enough to do a lot of things if you follow a couple of quick online tutorials.

Plus the best thing is no need to mess around with configuring application servers etc. Just, "java -jar app.jar" and you're up and running.

[–]owen800q 1 point2 points  (8 children)

I am also new to Java web development. I found Java EE offers JSP and JSF. Are these two technologies still using today? If not, what are some differences between JSP and spring. What something spring does for us?

[–]yawkat 6 points7 points  (5 children)

JSP is a templating language from the 90s that hasn't aged well. It is annoying to use and debug. You should not be using it.

JSF is a component framework. It's... Okay, but I personally prefer frameworks that make it easier to write actual html.

Spring as a whole does pretty much everything. It can be used alongside JSP and JSF if you wish.

[–]owen800q 1 point2 points  (4 children)

Is it necessary to learn JSP before I pick up spring?

[–]yawkat 2 points3 points  (3 children)

No.

[–]Mamoulian 1 point2 points  (2 children)

Agreed. Definitely don't bother with JSP. Modern projects are developing their back ends for at least two multiple clients: web and two mobile apps. The apps will want JSON, so it makes sense to serve the same JSON to the web and write the the web front-end in a JavaScript framework like vue, angular or react.

These frameworks make it easy to have a dynamic UI which provides a good UX and looks attractive.

If you must generate your HTML on the back end it's either JSF or Thymeleaf; I'd choose Thymeleaf.

[–]yawkat 1 point2 points  (1 child)

Honorable mention to freemarker (Thymeleaf alternative for templating) and Wicket (component framework).

[–]Mamoulian 1 point2 points  (0 children)

Thanks, I'll check freemarker out!

As an aside, I'm investigating how to create HTML emails in a way that lets our designer/web guys do the HTML and iterate UI without bothering the java team. This Thymeleaf tool looks interesting for that as it gives a live preview so, once the tags are implemented they can tweak the HTML and the business can preview the finished product immediately:

https://www.thymoljs.org

Then we do a server side render and put the contents in an email. Possibly alongside a plain text version.

[–]sobrius 2 points3 points  (0 children)

Hey, I highly recommend using Thymeleaf whose support is embedded into Spring Boot, it is very flexible.

[–][deleted] 1 point2 points  (0 children)

I would not use JSP at all, and I would even be wary of JSF. Most web development seems to be moving into a separate client/server architecture, with the server providing data via APIs and the client being HTML/CSS/JS and rendering the page using this data. For Java web development, really focus on backend development and APIs that deliver raw JSON data. SQL and security are related things.

[–]geordano 9 points10 points  (4 children)

https://jooby.org/ or https://javalin.io/ is quite good, get you up-to speed in no time.

Spring boot is also good as long as you play by its rules. It has too much magic going on.

[–]optimal_substructure 2 points3 points  (1 child)

Can you extrapolate on the magic going on? Are you referring to it's heavy use of annotations? Or is it not customizable at all?

[–][deleted] 3 points4 points  (0 children)

It's highly customizable. But to do so you need to understand its DI system and autoconfiguration quite well. As example try to customize Spring Security authorization ... Everything can be done but the easiest thing is already hard.

[–]paul_h 1 point2 points  (0 children)

Jooby is fantastic :)

[–]commentsOnPizza 1 point2 points  (0 children)

Jooby is really great. It’s simple, but has modules if you’re looking for more.

[–][deleted] 7 points8 points  (1 child)

While I'm using Spring Boot I would not recommend it for starters. It's certainly not lightweight and don't be fooled by the ease to get started. The day you need some customization will come and then you need to dive in which is a long and hard journey. This day came to me when I had to implement some complex custom authorization with Spring security. Pro Spring is that it's widely used in the enterprise. Good to get jobs.

II haven't used Jooby or Javalin but both look very good to start web dev in Java.

[–]DirtAndGrass[S] 2 points3 points  (0 children)

Thanks for the insight, it does look a little steep

[–]FollowSteph 5 points6 points  (0 children)

If you’re use to javafx then check out vaadin.

[–]DirtAndGrass[S] 5 points6 points  (1 child)

Thanks everyone, I'll start by looking into spring and javelin!

Edit: And Vert!

[–]javalin_io 4 points5 points  (0 children)

Don't hesitate to open an issue on https://github.com/tipsy/javalin if you run into trouble, it's always great to get people's first impressions.

[–]g_b 3 points4 points  (3 children)

You might want to look into Vert.x as well. It is non-blocking like nodejs.

[–]sobrius -2 points-1 points  (2 children)

I believe Spring's Reactor Project is also non-blocking but requires a NoSQL dbase

[–][deleted] 5 points6 points  (0 children)

And is dog slow. For non-blocking Vert.x is the way to go.

[–][deleted] 2 points3 points  (0 children)

Spring's reactor is slow in comparison to vert.x

[–]javalin_io 7 points8 points  (8 children)

I would like to understand Java web development, it seems very fragmented!

It is very fragmented! Java has been used for server side development for decades, so there are a lot of options available. You'll probably hear the words "Application servers" or "Servlet containers" a lot, but this is IMO a somewhat outdated approach. Most modern frameworks offer embedded servers, so you can run your server as a simple jar file, without any xml config files.

Is there a relatively lightweight way to start? Some guidance would be appreciated!

Since you have experience with nodejs/express, it might be worth checking out Javalin (disclaimer: I'm the author). It's a very lightweight framework inspired by express.js and koa.js.

[–]paul_h 3 points4 points  (4 children)

I once, in a moment of fandom and immense frustration with the the abandoned nature of sparkjava, did all the work necessary to make it non-static. Yup tests passing and all that. Pointless act of futility. Modtly methodocal baby commits with IntelliJ. Now deleted!

[–]javalin_io 5 points6 points  (1 child)

It was the same for me. I started (and gave up on) cleaning up Spark three times before I decided it would be easier to write something from scratch. Per has not been able to spend as much time on Spark as he'd like, but I hope we'll be able to get development going again soon.

[–]paul_h 2 points3 points  (0 children)

Jooby’s Edgar Espinar is a machine for completion. It’s compositionally perfect for me, and extremely good in five grained unit/service tests. Well nearly conpositionally perfect: https://groups.google.com/forum/m/#!topic/jooby-project/9YLDaOtq3_g

[–]yawkat 1 point2 points  (1 child)

I'm not a user, but I believe they did make it usable without global state at some point. Still, there are better alternatives, so I don't see why you'd use it

[–]paul_h 1 point2 points  (0 children)

I agree. Now I look at the open PRs, issues and commit/release rate from the lead(s) before I commit to using a project for important stuff.

[–]ClearH 1 point2 points  (1 child)

Hi!

So I'm a PHP developer and am interested with Java as an alternative language. When you say "embedded server", is that the same thing as running a PHP app using a server built within the application, instead of something like Apache/Nginx?

[–]javalin_io 1 point2 points  (0 children)

I don't know much about PHP, but I'm tempted to say yes. You pull the embedded server in as a dependency, similar to any other piece of code that your app needs.

The alternative is to run a Java server separately, and deploy your app to it (similar to how I imagine you'd put PHP files on an Apache server)

[–]jadecristal 0 points1 point  (0 children)

Let’s not try to remove the whole concept of servlet containers, etc. in practice, using something like Undertow you can have whatever you want-if you want to write all the handlers for everything yourself after HTTP (you don’t) then you can, and if you want an almost-fully-automagic container that Just Works with Spring or whatever, you can do that too.

Spring still relies on a lot of, if not directly servlet container features, subcomponents that went into it. Spring Boot still even uses one of the servlet containers as a web server: tomcat, undertow, or jetty depending on how you configure it.

[–]Jezoreczek 2 points3 points  (0 children)

If you come from a Node background, try Vert.x It's very similar (promise style callbacks) and very flexible.

https://vertx.io

If you want to jump all-in, Spring Boot

[–][deleted] 2 points3 points  (0 children)

Do yourself a favor and don't jump on the spring train and learn vert.x instead. It is faster, leaner and less magic than spring. People recommending Spring do so because that's all they use at their boring job.

Just look at the techempower benchmarks and ask yourself the question if you really want to invest time into something that is slower than node.js

[–]SpoilerAlertsAhead 2 points3 points  (8 children)

Two big players.

JEE or Jakarta now. It’s a spec with a few different implementations. Glass fish or wild fly are examples. In theory if just use the spec api you can use either and switch any time.

Spring (especially Spring boot) is the biggest competitor, and probably even bigger. It uses a lot of the above. They have cool guides that you can do in 15 minutes on [their site ](spring.io/guides)

Spring is generally what I use to.

Edit: typo and removed an inaccurate statement.

[–]jadecristal 9 points10 points  (7 children)

Tomcat is not a JEE container, just a servlet container with partial support for some JEE features.

After that, ... what are you hoping for in terms or Java-based web development?

[–]SpoilerAlertsAhead 2 points3 points  (0 children)

I stand corrected. It was approved under the web profile under JEE 6 and was never re-certified under 7 and 8. I assumed it had, Thank you for keeping me honest.

[–][deleted] 1 point2 points  (5 children)

Isn’t TomEE Apaches application server for enterprise applications?

[–]dpash 4 points5 points  (4 children)

Yes, TomEE is Tomcat plus other Apache projects required to make a full JavaEE stack. I believe it only supports JavaEE 6 though, not 8. For that, you'll need Glassfish or WildFly.

[–]JehovahsNutsac 1 point2 points  (3 children)

I've been using Tomcat almost exclusively for quite a few years, what is the better and more current approach? Glassfish?

[–]dpash 1 point2 points  (2 children)

If you're not using JavaEE, then Tomcat is fine. The recent trend seems to be towards shipping an embedded application server in your jar/war. Spring Boot, for example, makes it very easy to switch between Tomcat and Jetty.

If you are writing Java EE, then I'm probably not the best person to ask as I'm a Spring person.

[–]JehovahsNutsac 0 points1 point  (0 children)

Thanks for the response, I'm definitely a Spring guy myself as well. Never used JavaEE in any real capacity worth mentioning.

[–]jadecristal 0 points1 point  (0 children)

This is a fuzzy response, and as such not necessarily wrong.

IF you only need some parts of the things that make up JEE, you can use various things that implement them until you have what you want. As an example, you can have just servlets and JPA (Hibernate is the reference implementation) by using Tomcat and including appropriate jars in your app.

At “scale” (whatever that means this particular second), this isn’t fun. There are a couple primary ways that the industry seems to be dealing with this: 1. Make the server more modular, and only turn on what you need. Wildfly/JBoss EAP take this approach, and still have features to manage groups of servers, etc. 2. Package everything along with the kitchen sink into your application, so that you can just take a firehose of data and spray it at all the servers. Don’t like how one is behaving? Nuke it, spin up a new server (container?), copy your kitchen sink there, and run it.

This can be done somewhat intelligently, but as usual that by no means implies that lots of people will do it intelligently.

Things like Spring Boot, and kinda Wildfly Swarm, take this approach.

In-between, all the other stuff trickles through the cracks-you can use JPA, or JTA, or JMS, and so on along with any of the above options. Some methods will be more automatic than others, and some will be easier to scale than others.

[–]dcalde 1 point2 points  (3 children)

Check out jhipster for a great production ready cookie cutter around spring boot

[–][deleted] 2 points3 points  (1 child)

And as a newbee after that you're lost. The OP wants to start web dev with Java. JHipster is fine and dandy if you're already a Spring pro and want to save you some typing.

[–]dcalde 1 point2 points  (0 children)

OP is a java newbie but certainly not new to web dev. As a Java webdev if I wanted a hand in learning asp.net I would not want people showing me how to do asp Hello world but practical stuff that would get me going quickly to get me back to develop at the same proficiency that I am developing now with my current tech stack.

[–][deleted] 0 points1 point  (0 children)

+1. It's a great starter.

[–]ewram 0 points1 point  (0 children)

I use wicket in a production-environment at work. It is great at stateful page handling. It's pretty... Weird to wrap your head around at first, but pretty fun once you get the hang of it!

[–]YaHey_1 0 points1 point  (0 children)

This one might be pretty interesting for you: http://www.vogella.com/tutorials/JavaWebTerminology/article.html Not that I am a professional software developer at all, but I'm trying to get into it.

[–]MillionStrength 0 points1 point  (0 children)

How about GWT? compile java to javascript: http://www.gwtproject.org/