I have implemented simple com.sun.net.httpserver.HttpServer application using one of examples in the internet.
Server get request as expected except for one exception:
if url contains tspecials: ” or ‘<‘ “/” request doesn’t reach the server at all.
Using simple java.net.ServerSocket all works great and request received where all tspesials are encoded, which is great for me, but i prefer use HttpServer.
for example request: http://127.0.0.1/MyApp/Test?var=<xml id=“1“>value</xml>
works for ServerSocket and not working for HttpServer.
Any help will be appreciated.
You need to encode your urls on the client side, using the % notation:
http://127.0.0.1/MyApp/Test?var=%3Cxml+id%3D%271%27%3Evalue%3C%2Fxml%3E
On the server side, you should use URI.getRawQuery() in case the query contains & characters, and décode parameter values with URLDecoder.decode.