- Home
- >
- Software Development
- >
- Don’t Sleep on the Simple Web Server – InApps 2022
Don’t Sleep on the Simple Web Server – InApps is an article under the topic Software Development Many of you are most interested in today !! Today, let’s InApps.net learn Don’t Sleep on the Simple Web Server – InApps in today’s post !
Read more about Don’t Sleep on the Simple Web Server – InApps at Wikipedia
You can find content about Don’t Sleep on the Simple Web Server – InApps from the Wikipedia website
When Oracle released Java 18 last month, one of its slightly overlooked but interesting new features was the Simple Web Server.
Oracle introduced the Simple Web Server via Java Enhancement Protocol (JEP) 408. The JEP 408 proposal describes the Simple Web Server as providing a command-line tool and API to start a minimal web server that serves static files only. There is no CGI or servlet-like functionality available.
For Prototyping, Testing, Etc.
The tool is intended for use in prototyping, ad-hoc coding and testing, particularly in educational contexts, Oracle said.
The Simple Web Server is a minimal HTTP static file server that was added in JEP 408 to the jdk.httpserve module, said Julia Boes, an OpenJDK developer in Oracle’s Java Platform Group, in a blog post. It serves a single directory hierarchy, and it serves only static files over HTTP/1.1; dynamic content and other HTTP versions are not supported, she wrote.
“The web server’s specification is informed by the overarching goal of making the JDK [Java Development Kit] more approachable,” Boes said. “The server is an out-of-the-box tool with easy setup and minimal functionality that lets you hit the ground running and focus on the task at hand. The simplistic design also avoids any confusion with feature-rich or commercial-grade servers — after all, far better alternatives exist for production environments, and the Simple Web Server is not the right choice in such cases.”
Indeed, another goal is to reduce developer activation energy and make the JDK more approachable. A third goal is to provide a default implementation via the command line together with a small API for programmatic creation and customization.
Command-Line and API
The simplified server can be used via the dedicated command-line tool jwebserver or programmatically via its API. From the command line, use command $ jwebserver to start the Simple Web Server. Oracle also defines new APIs for server creation and customized request handling with the new feature.
“The Simple Web Server was designed to facilitate prototyping, debugging, and testing tasks, and I hope the combination of a minimal command-line tool and a flexible set of API points achieves this goal,” Boes said. “The jwebserver tool brings basic server functionality to the command line, while the Simple Web Server API points offer fully customizable server components that can help tackle less-common scenarios and corner cases.”
Aimed at New Developers
The new tool is particularly useful for developers who are new to Java and for educators, basically making it easy for students to get up and running, starting a web server and having all the infrastructure that they need for writing a Java application be provided for them simply, Georges Saab, vice president of software development for the Java Platform Group at Oracle, told InApps.
“The Simple Web Server represents our continued investments to make Java more approachable for the next generation of developers. And to make it really easy for students and educators to pick up Java. And to do something cool out of the box without having to introduce lots of new concepts,” Chad Arimura, vice president of developer relations at Oracle, told InApps.
For instance, spinning up a web server, downloading NGINX and getting it to run and then writing Java code on top of that and deploying it, includes several steps that students don’t want to learn, he said, noting that the server is probably his favorite feature in Java 18.
“With a simple web server, you download the JDK, you type jwebserver, it fires up a loopback to your interface for local host and it automatically generates an index.html file with some Java code, and you’re off to the races with almost no thinking whatsoever. And then you can start kind of inserting your own code,” Arimura said. “So I thought that was pretty cool in conjunction with Java. With the JShell tool, you can do a lot of really cool things at the command line now that you couldn’t do before.”
However, seasoned Java professionals like Simon Ritter, deputy CTO of Azul Systems, said they were a bit confused by what seems like a change in direction with the new simple server.
“I get it, it’s for testing,” Ritter said. “But I know that when we got to JDK 9, one of the big things that the developers of OpenJDK said was we really want to try and strip out all the superfluous stuff that we included in the JDK and kind of get it down to the core stuff that you need for developing Java. And, you know, that’s great, except now we’re kind of going back the other way. Let’s include a web server. Why? I mean, do we really need a web server?”
Yet, the JEP 408 description spells out Oracle’s thinking on the issue.
“It is not a goal to provide a feature-rich or commercial-grade server,” the description reads. “Far better alternatives exist in the form of server frameworks (e.g., Jetty, Netty, and Grizzly) and production servers (e.g., Apache Tomcat, Apache httpd, and NGINX). These full-fledged and performance-optimized technologies take effort to configure, which is exactly what we want to avoid.”
However, with a small out-of-the-box server, developers, particularly newbies, can perform:
- Web development testing, where a local testing server is used to simulate a client-server set up.
- Web-service or application testing, where static files are used as API stubs in a directory structure that mirrors RESTful URLs and contains dummy data.
- Informal browsing and sharing of files across systems to, for example, search a directory on a remote server from your local machine.
“Python, Ruby, PHP, Erlang, and many other platforms offer out-of-the-box servers run from the command line,” said the JEP 408 description. “This variety of existing alternatives demonstrates a recognized need for this type of tool.”
Overall, this represents good and steady progress by Oracle with Java, which is what both developers and CxOs expect from a programming language platform provider, said Holger Mueller, an analyst at Constellation Research.
“The addition of a simple web server is key for developer velocity, as developers can test and validate code early, more easily and faster,” he noted.
Jam-Packed with Features
In addition to the Simple Web Server, Java 18 packs in thousands of performance, stability and security improvements, including nine enhancements to improve developer productivity.
These include the capability to add Code Snippets in Java API Documentation (JEP 413), which simplifies the addition of sample source code in API documentation, and Simple Web Server (JEP 408) for prototyping and testing. Developers can also try out two incubating modules: the Vector API (JEP 417) and the Foreign Function and Memory API (JEP 419), as well as a preview feature: Pattern Matching for Switch (JEP 420).
However, “it’s not necessarily all about features,” Sharat Chander, senior director of Java and container native product management and developer relations at Oracle, told InApps, “because with every release, it’s also about performance.” Chander said, “Just having the ability to utilize a new runtime to get out-of-the-box improvements over a previous version on a new one is, to me, a reason to keep up because performance is so critical to modern application development.”
Pattern Matching for Switch
JEP 420 is in its second preview. It provides pattern matching for switch expressions and statements, along with extensions to the language of patterns. Extending pattern matching to switch allows an expression to be tested against a number of patterns, each with a specific action, so that complex data-oriented queries can be expressed concisely and safely.
Saab called pattern matching for switch one of his favorite features. “It’s in the arc of support for immutable data and reasoning over it,” he said. “The style of coding that it allows is just really handy and intuitive.” Saab said, “Although this is sort of a small piece of a larger set of improvements that’s coming to Java in terms of the way that people program, I think in a few years, we’re going to look back and just be like, ‘Oh, my God, how do we ever live without that,’ right?”
Overall, with its six-month release cadence for Java, Oracle is providing a smooth continuation of work begun with earlier releases, like pattern matching for switch.
“With JEP 420 including extended pattern matching that will help Java developers do a lot more with data-oriented queries — a capability and mindset that will serve Java well within an increasingly data-oriented application marketplace,” said Brad Shimmin, an analyst at Omdia. “Regardless, this ‘slow burn’ approach to rolling updates is crucial, as it enables developers to start using both fully baked and newly introduced functionality more rapidly and without risk or complexity.”
Featured image via Pixabay.
Source: InApps.net
Let’s create the next big thing together!
Coming together is a beginning. Keeping together is progress. Working together is success.