How can i make HttpServer recognise special C
Résolu
chouaieb.n
Messages postés
1
Date d'inscription
Statut
Membre
Dernière intervention
-
chossette9 Messages postés 4239 Date d'inscription Statut Contributeur Dernière intervention -
chossette9 Messages postés 4239 Date d'inscription Statut Contributeur Dernière intervention -
Bonjour,
0 down vote favorite
share [fb] share [tw]
i want to make some Sql query with my java HttpServer but i seems to be that the HttpServer don't recognise special characters the link i must submit into my browser is like :
[1]: http://localhost:8001/test?query=SELECT * WHERE{ ?s rdf:type ?o. }
but i always recieve this response :
400 Bad Request URISyntaxException thrown
this is the code for my server :
public class SimpleHttpServer {
public static void main(String[] args) throws Exception {
dir = args[0];
HttpServer server = HttpServer.create(new InetSocketAddress(8001), 0);
server.createContext("/test", new MyHandler());
server.setExecutor(null);
server.start();
}
static class MyHandler implements HttpHandler {
public void handle(HttpExchange t) throws IOException {
String response ;
System.out.println(t.getRequestURI().getQuery().toString().replaceAll("query=", ""));
response = ExecuteHttpQuery.getInstance().httpQuery(t.getRequestURI().getQuery().toString().replaceAll("query=", "").toString(), dir) + "\n";
t.sendResponseHeaders(200, response.length());
OutputStream os = t.getResponseBody();
os.write(response.getBytes());
os.close();
}
}
} can anyone help me please ?
Many thanks.
0 down vote favorite
share [fb] share [tw]
i want to make some Sql query with my java HttpServer but i seems to be that the HttpServer don't recognise special characters the link i must submit into my browser is like :
[1]: http://localhost:8001/test?query=SELECT * WHERE{ ?s rdf:type ?o. }
but i always recieve this response :
400 Bad Request URISyntaxException thrown
this is the code for my server :
public class SimpleHttpServer {
public static void main(String[] args) throws Exception {
dir = args[0];
HttpServer server = HttpServer.create(new InetSocketAddress(8001), 0);
server.createContext("/test", new MyHandler());
server.setExecutor(null);
server.start();
}
static class MyHandler implements HttpHandler {
public void handle(HttpExchange t) throws IOException {
String response ;
System.out.println(t.getRequestURI().getQuery().toString().replaceAll("query=", ""));
response = ExecuteHttpQuery.getInstance().httpQuery(t.getRequestURI().getQuery().toString().replaceAll("query=", "").toString(), dir) + "\n";
t.sendResponseHeaders(200, response.length());
OutputStream os = t.getResponseBody();
os.write(response.getBytes());
os.close();
}
}
} can anyone help me please ?
Many thanks.
A voir également:
- How can i make HttpServer recognise special C
- Caractere special - Guide
- I showkeyplus - Télécharger - Utilitaires
- Symbole special - Guide
- I sans point ✓ - Forum Windows
- Bouton on off o i - Forum Word