D
D
D8i2018-11-10 17:53:17
Java
D8i, 2018-11-10 17:53:17

How to get fragment (everything after #) from URI on apache http server?

There is a simple http server that receives a GET request.

public class Server {
    public static void start() {
        HttpServer server = ServerBootstrap.bootstrap()
                .setListenerPort(80)
                .registerHandler("/listener", new Handler())
                .create();
        try {
            server.start();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    private static class Handler implements HttpRequestHandler {
        @Override
        public void handle(HttpRequest request, HttpResponse response, HttpContext context) throws IOException {

        }
    }
}

With requests of the form:
http://localhost/listener?arg_first=1&arg_second=2
copes without problems.
But it is only necessary to replace '?' problems start with '#'. With a query like this:
http://localhost/listener#arg_first=1&arg_second=2
I can't seem to get everything beyond '#' to be shown to me.
As I understand it, this is called a fragment, but it didn’t really give me anything. Kind people, help me understand and get my arguments.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dmitry Roo, 2018-11-10
@D8i

Anything after # is not sent to the server.
You can try using js on the client side for processing.

S
StainlessDespair, 2018-11-11
@StainlessDespair

request.uri().getFragment​()
To split into parts, you can use the split() method.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question