applet和servlet通讯的问题
我在applet中向servlet传送数据,想传给servet的doget()方法,
程序如下:
String serverURL;
//servlet的url,这样直接访问可以吗?
serverURL = getCodeBase()+"myPage/servlet/gisserver.DataServer";
output.setText("connect to: " + serverURL);
String queryString = query;
output.setText("Attempting to send:" + serverURL);
//建立与Servlet的联接,向Servelt传输数据
// Get the server URL
URL url = new URL(serverURL);
// Attempt to connect to the host
URLConnection con = url.openConnection();
// Initialize the connection
con.setDefaultUseCaches(false);
con.setUseCaches(false);
con.setDoOutput(true);
con.setDoInput(true);
con.setRequestProperty("Content-type", "application/x-www-form-urlencoded");
con.setRequestProperty("Content-length", String.valueOf(queryString.length()));
OutputStream out = con.getOutputStream();
out.write(queryString.getBytes());
out.flush();
但是在调用时,在applet控制台返回的出错信息如下,不知什么意思。请高手分析指教:
java.io.IOException: Server returned HTTP response code: 405 for URL: http://localhost/myPage/servlet/gisserver.DataServer
因为“405”信息说明是不正确的方法调用,小弟有几个疑问:
1.我用的服务器是apache+tomcat,这样向服务器的servlet传数据可以吗?
2.这些数据是通过doGet()方法响应吗?
3.到底哪里错了?
请高手指教,万分感谢,
如果搞定,随便多少分都送!