Error en el envio de url a servlet
Publicado por Javier (4 intervenciones) el 26/04/2007 13:43:25
Hola, tengo un problema con mi programa. Intento enviar una url a un servlet por método GET, sin embargo el mensage de error que me sale es 'El Metodo HTTP POST no es soportado por esta URL ', mi código es este:
public void doGet(HttpServletRequest req,HttpServletResponse res) throws IOException{
PrintWriter out=res.getWriter();
String protocol = "http";
String host = "localhost";
int port = 8080;
String file = "/DeegreeProject/wms";
URL url = new URL(protocol,host,port,file);
HttpURLConnection enlace = (HttpURLConnection) url.openConnection();
enlace.setRequestMethod("GET");
enlace.setDoOutput(true);
enlace.setDoInput(true);
OutputStreamWriter os = new OutputStreamWriter(enlace.getOutputStream(),"UTF-8");
os.write("GET" + url.toExternalForm()+ "HTTP/1.0\r\n");
os.write("Host: " + url.getHost()+"\r\n");
os.flush();
os.close();
out.println(enlace.getResponseMessage());
}
Alguien podría decirme porqué trata del método Post cuando todo está relacionado al método get?
Gracias
public void doGet(HttpServletRequest req,HttpServletResponse res) throws IOException{
PrintWriter out=res.getWriter();
String protocol = "http";
String host = "localhost";
int port = 8080;
String file = "/DeegreeProject/wms";
URL url = new URL(protocol,host,port,file);
HttpURLConnection enlace = (HttpURLConnection) url.openConnection();
enlace.setRequestMethod("GET");
enlace.setDoOutput(true);
enlace.setDoInput(true);
OutputStreamWriter os = new OutputStreamWriter(enlace.getOutputStream(),"UTF-8");
os.write("GET" + url.toExternalForm()+ "HTTP/1.0\r\n");
os.write("Host: " + url.getHost()+"\r\n");
os.flush();
os.close();
out.println(enlace.getResponseMessage());
}
Alguien podría decirme porqué trata del método Post cuando todo está relacionado al método get?
Gracias
Valora esta pregunta


0