Achieve is a modern HTTP server that runs on Node.js and uses JavaScript Servlets to initiate back end processing. (npm, github) JS Servlets are fast, very easy to use, and do not limit your ability to develop sophisticated back end applications; perfect for rapid development of microservices or complete Node.js based web applications. You can even use it just to serve web pages.
A servlet is a small program that runs on a server. The term has long since been associated with Java. Java Servlets provide the interface between servers and back-end application programs written in Java. This new server implementation, named Achieve, provides a JavaScript Servlet implementation on Node.js. If you are familiar with Java Servlets, you should easily see general similarities in the new JS Servlet design.
The initial motivation for Achieve was to include web application development in early programming courses (including web development courses). Ease of use, especially in exchange of utf-8 text (the default for HTML5) was an absolute requirement. JavaScript was an obvious choice of language.
A variety of considerations motivated use of the servlet concept, inspired by Java servlets. Reading through the quick-start guide, you will see that with the special features of JS Servlets, Achieve is very easy to use. But no one should be held back by tool limitations. Ease of use is a feature, not a limiting characteristic. The JS Servlet Context object, along with full access to Node.js and all the node modules that exist provides a path to a complete professional experience. Finally, early experience with Achieve makes it easier to introduce Java Servlets in a later course.
Real Developers Don't Need Unnecessary Complexity! As work proceeded on Achieve, it became clear that the implementation was efficient enough for production. In addition, its basic features would be helpful to developers as well as students.
- Achieve leaves application components loaded in memory as would be expected in production, BUT automatically reloads them when the code has been changed.
- Achieve delivers error messages for display in the browser or browser console in the same form as errors in browser code, allowing one point of focus during development and test.
- Achieve can handle the entire process of returning a response handed back to it through the servlet's return statement.
- Achieve default is utf-8 plain text, but you can change the MIME type and encoding (in fact, set any header) and still use the servlet return statement, allowing Achieve to finish the response.
- You can set the application folder to any directory you have access to (including network directories) and set a subdirectory for the root application.
- You can take complete control, as in any Node.js application, via access to the request and response in the servlet's Context object.
- You can list the MIME types currently supported by Achieve and add other MIME types as needed.
- Achieve supports browser caching (ETags) and compression (gzip,deflate).
- You can build back-end applications with Achieve in combination with other node modules.
A Separate Servlet Container! JS Servlets alone can, in some circumstances, be a good choice for running microservices. Module servlets.js is the servlet portion of Achieve. It is Achieve without the static content server code. Although this may increase speed when speed is critical, the following should be considered when making a choice.
Because servlets.js is the servlet support portion of Achieve, you can develop using Achieve and switch to servlets.js in production.
Achieve allows microservice developers to work independently through unit testing, leaving integration to a time when other components are well developed. Triggering back-end processes through your browser is easy to do and the way Achieve delivers error messages to the browser can help you debug. This simplifies the development process by allowing focus on one thing at a time. You can easily develop monitoring tools for your microservices with the browser as the GUI. Achieve runs through the serve vs. run decision quite efficiently. If you really feel the need to trim microseconds through coding, you probably need a faster computer.
Achieve and servlets.js were developed as part of the High Level Logic project (HLL). They are both available via npm and github, free and open source under MIT license.