Java, Helidon SE get URL query string parameters example

Hello everyone, Today, we will show you how to create a simple REST API with Helidon SE 2.5.0 and Java 17 and how to get URL query string parameters.

Quick Overview:

  • Helidon SE is designed to be a microframework that fortifies the reactive programming model. Helidon SE features three core APIs to engender a microservice -- a web server, configuration, and security -- for building microservices-predicated applications. 
  • Helidon's web server is an asynchronous and reactive API that runs on top of Netty. The WebServer interface includes support for configuration, routing, error handling, and building metrics and health endpoints.
  • The Config loads and processes configuration properties( or application.yaml) in key/value format. 
  • The Security class provides support for authentication, sanction, and audit.
  • Query parameters are a defined set of parameters affixed to the end of a url. They are extensions of the URL that are used to avail define specific content or actions predicated on the data being passed.

Final Project Directory:

Maven [pom.xml]:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns=""


<description>Demo project for Helidon SE</description>




import java.util.Collections;
import javax.json.Json;
import javax.json.JsonBuilderFactory;
import io.helidon.config.Config;
import io.helidon.webserver.Routing.Rules;
import io.helidon.webserver.ServerRequest;
import io.helidon.webserver.ServerResponse;
import io.helidon.webserver.Service;

public class MyService implements Service {

private static final JsonBuilderFactory JSON = Json.

MyService(Config config) {

public void update(Rules rules) {
rules.get("/", this::getDefaultMessageHandler);

private void getDefaultMessageHandler
(ServerRequest request, ServerResponse response) {
var params = request.queryParams().toMap();
System.out.println("name: " + params.get("name").get(0));
System.out.println("email: " + params.get("email").get(0));

sendResponse(response, params.get("name").get(0));

private void sendResponse
(ServerResponse response, String name) {

var returnObject = JSON.createObjectBuilder().
add("name", name).build();



import java.util.logging.Logger;
import io.helidon.common.reactive.Single;
import io.helidon.config.Config;
import io.helidon.webserver.Routing;
import io.helidon.webserver.WebServer;

public class HelidonSeRestApplication {

private static final Logger LOGGER = Logger.

public static void main(final String[] args) {

private static Single<WebServer> startServer() {

// Load the default configuration using
// the create() method.
var config = Config.create();

var server = WebServer.builder(createRouting(config))

// Start web server
var webserver = server.start();

webserver.thenAccept(ws -> {"Web server started! http://localhost:"
+ ws.port() + "/hello");
ws.whenShutdown().thenRun(() -> LOGGER.
info("Web server is down!"));
}).exceptionallyAccept(t -> {
LOGGER.severe("Web startup failed: " + t.getMessage());

return webserver;

private static Routing createRouting(Config config) {

var helloService = new MyService(config);

return Routing.builder()

.register("/hello", helloService).build();

Local Setup and Run the application:

Step1: Download or clone the source code to a local machine. - Click here

Step2: mvn clean install

Step3: Run the Main java application

Console output:

name: knowledgefactory 

Popular posts from this blog

Learn Java 8 streams with an example - print odd/even numbers from Array and List

Spring boot video streaming example-HTML5

Spring Boot + Mockito simple application with 100% code coverage

Spring Boot + OpenCSV Export Data to CSV Example

Custom Exception Handling in Quarkus REST API

Registration and Login with Spring Boot + Spring Security + Thymeleaf

DataTable-Pagination example with Spring boot, jQuery and ajax

Spring Webflux File Download - REST API Example

Node JS mini projects with source code - free download

ReactJS, Spring Boot JWT Authentication Example