Friendly in development. Fast in production. Just build your apps. Let Achieve do the rest.

← Back to main examples index
Use the tabs to inspect the code behind this demonstration.

XML-SAX

From the extracted distribution, run npm start. Refresh this page if needed after starting the server.

It's all about speed. For Content-type xml, Achieve quickly routes and gets out of the way, passing the request stream to the servlet. With session.autoEnd=false, Achieve goes on to other work while the servlet is free to use the request and response streams directly.

SAX is a perfect companion. It doesn't create a DOM object. @nodable/sax processes the stream in chunks and begins returning decomposed elements as they are produced. This results in direct simultaneous streaming in both directions. The web page builds the table as each new line of data arrives.

@nodable/sax is an application/example dependency, not an Achieve dependency. Install the application dependencies from the Achieve examples directory with npm install.

Underlying mechanics: Achieve parses GET query parameters and POST input for application/json and application/x-www-form-urlencoded, delivering a convenient JavaScript object to the servlet as session.params. For other content types, as in this XML example, Achieve passes the request stream directly to the servlet. For more information, see the Servlets Reference. Even when achieve parses input, it still also delivers the original request and response objects as session.request and session.response.

Needs server running.
ID In Stock Title Price