users@grizzly.java.net

URLDecode requests

From: Oliver Schrenk <oliver.schrenk_at_gmail.com>
Date: Thu, 25 Mar 2010 17:25:04 +0100

Hi,

I'm using grizzly-http-webserver-1.9.18-k to serve static files, but also need support for URL-encoded requests (in UTF-8). Is it possible to forward the request, response to the default Adapter? Something like:

GrizzlyAdapter ga = new GrizzlyAdapter(rootDirectory.toString()) {

        @Override
        public void service(GrizzlyRequest request, GrizzlyResponse response) {
                String uri = "";
                try {
                        uri = URLDecoder.decode(request.getDecodedRequestURI(), "UTF-8");
                } catch (UnsupportedEncodingException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                }
                request.setDecodedRequestURI(uri);
                dispatch(request, response);
        }
};
ws.addGrizzlyAdapter(ga, new String[] { "/*" });

Or is there another (better) way?

Best regards
Oliver