Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jetty Server - how to handle a GET request with parameters?

This must be awfully simple, but I didn't find an answer.

Here is an easy example on how to listen to a get request with a jetty server.

However, it doesn't cover the case that it's not just a "http://www.foo.com/bar" request, but something like "http://www.foo.com/bar?name=guy&value=1".

So how do I get the parameters in jetty?

like image 339
jellyfish Avatar asked Apr 26 '11 12:04

jellyfish


People also ask

Can we pass parameters in GET request?

get() method. Using the params property we can pass parameters to the HTTP get request. Either we can pass HttpParams or an object which contains key value pairs of parameters.

How do I get parameters in GET request?

GET parameters (also called URL parameters or query strings) are used when a client, such as a browser, requests a particular resource from a web server using the HTTP protocol. These parameters are usually name-value pairs, separated by an equals sign = .

How does a Jetty server work?

The Jetty Server is the plumbing between a collection of Connectors that accept HTTP connections, and a collection of Handlers that service requests from the connections and produce responses, with the work being done by threads taken from a thread pool.


1 Answers

This is the API for ServletRequest. You should use:

request.getParameter("name");
request.getParameter("value");
like image 63
Sebastien Lorber Avatar answered Sep 22 '22 11:09

Sebastien Lorber