Abstract
Spring can certainly be used in a standalone environment, but the most common environment for Spring has historically been in an enterprise environment, powering web applications and backend services in a managed server. This chapter will demonstrate some aspects of integration in a Jakarta EE container (formerly known as Java EE, or J2EE, or maybe even just "Tomcat" depending on your level of exposure, currency, and experience).
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Notes
- 1.
Java has always had confusion around names and versions: for example, there used to be a release called J2SE 4, which was “Java 2, Standard Edition,” version 1.4. The 1.4 edition was also edition 4, and most people without a lot of exposure to Java spent a lot of time wondering what versions referred to what components. This was something that plagued Sun, the company that created Java, and has never really gone away.
- 2.
Wait, there’s the word “context” again. Spring application contexts aren’t quite the same as Jakarta EE application contexts, but they’re similar; they just don’t have the same roles at all. Remember, we warned you that this could get interesting.
- 3.
There are multiple HTTP specifications, because HTTP can do a lot and in a lot of different ways. A useful reference for the “basic HTTP specification” as everyone thinks of it is for HTTP 1.1: see https://tools.ietf.org/html/rfc2616 – but note that that’s definitely not the final word on HTTP.
- 4.
Servlet has a service(ServletRequest, ServletResponse); HttpServlet overrides this method to delegate to a service(HttpServletRequest, HttpServletResponse) method, which – if not overridden itself – will delegate to doGet(), doPost(), and so forth.
- 5.
JSON (“JavaScript Object Notation”) and XML are both structured data formats, with XML being a formal data format and JSON being far more convenient for both humans and, well, Javascript to read.
- 6.
They will not, however, survive this chapter. They’re written with manual Servlet processes in mind, which is what programmers used to have to do back before Facebook was a thing. Spring has a better way; we’ll see what that is in Chapter 6. In the meantime, these Servlets will help us validate what we’re learning in this chapter. With that said, we’re going to be writing equivalents over and over again.
- 7.
The management of transitive dependencies is one of the things that make build tools in Java like Maven or Gradle so absolutely necessary. Without transitive dependencies, programmers would have to chase down the entire dependency tree for every library they used. The transitive dependency mechanism built into the tools is far, far, far better.
- 8.
So now, if anyone ever asks you what war is good for, you can tell them with a straight face that wars are good for deploying web applications built in Java. Everyone wins, but be careful: this might get a cup of coffee thrown at you.
- 9.
Mustache is a very simple, largely logic-less templating library. There are many implementations in many languages. We’re using it here because of its simplicity; because most rendering happens on the client side in modern web applications, it’s not particularly relevant for most applications.
- 10.
We’ve already shown two Servlets, but they don’t run properly – because we haven’t shown how to populate the Servlet context with a Spring context yet. The Servlet here is a “Hello, World” Servlet, something to make sure our project is working properly. Once we know that we’re able to run a Servlet container and interact with it, we’ll have validated our process and we won’t need to go back over it – only replicate it.
- 11.
It’s “bated” breath and not “baited,” no matter how much your authors wanted to seem as if they’d been eating fish.
- 12.
Curl can be found at https://curl.haxx.se/ – if it’s not already installed on your OS, convenient downloads can be found at that site.
- 13.
We’ll be introducing @Controller and other such annotations in Chapter 6.
- 14.
It actually scans entire package trees – so any packages that have the scanned packages as their roots will be scanned as well. We could also use the Java configuration approach, and not scan at all; see Chapter 3 for how to do this.
- 15.
So many contexts!
- 16.
It’s “incredibly useful,” so to speak: Chapter 6 will show us how to get around pretty much all of this. But this is basically what’s happening behind the scenes.
Author information
Authors and Affiliations
Rights and permissions
Copyright information
© 2024 The Author(s), under exclusive license to APress Media, LLC, part of Springer Nature
About this chapter
Cite this chapter
Ottinger, J.B., Lombardi, A. (2024). Spring and Jakarta EE. In: Beginning Spring 6. Apress, Berkeley, CA. https://doi.org/10.1007/978-1-4842-9833-6_5
Download citation
DOI: https://doi.org/10.1007/978-1-4842-9833-6_5
Published:
Publisher Name: Apress, Berkeley, CA
Print ISBN: 978-1-4842-9832-9
Online ISBN: 978-1-4842-9833-6
eBook Packages: Professional and Applied ComputingApress Access BooksProfessional and Applied Computing (R0)