????????????????????????servlet????е?helloServlet.class?е????
????1??????д????????
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.net.HttpURLConnection;
import java.net.URL;
public class webtest {
public static void myFun(){
try{
String[] arr = {"aaa"??"bbb"??"ccc"??"ddd"};
String tempGisEngineUrl = "http://sun:8080/helloapp/hello?name=?й?";//hello????servlet?????web.xml???????url?????????
URL imsServerURL = new URL(tempGisEngineUrl);
HttpURLConnection imsConnection = (HttpURLConnection) imsServerURL
.openConnection();
imsConnection.setDoInput(true);
imsConnection.setDoOutput(true);
imsConnection.setUseCaches(false);
imsConnection.setDefaultUseCaches(false);
imsConnection.setRequestProperty("Content-Type"??
"application/octet-stream");
ObjectOutputStream oos = new ObjectOutputStream(imsConnection
.getOutputStream());
oos.writeObject(arr);//д?????????
oos.flush();
oos.close();
ObjectInputStream ois = new ObjectInputStream(imsConnection
.getInputStream());
String oResult = (String)ois.readObject();//??????????
ois.close();
imsConnection.disconnect();
System.out.println("from servlet:"+oResult);//???????????????????????????????
}catch(Exception ex){
System.out.println(ex.getMessage());
}
}
public static void main(String[] args){
myFun();
}
}
???????????н????
????1????servlet???????
????aaa
????bbb
????ccc
????ddd
????2?????????????from servlet:?й?
???????
???????service??????
????Servlet?????????????????????????????HTTP????request??????????HTTP?????response???????????????service???????????service??????????request?????????????????response???????????
??????????Servlet??javax.servlet.http.HttpServlet??У??????doPost??doGet????????????Servlet????POST??GET????????????????????????????????????request?????????????service?????????????????????service?????????????doPost??doGet????????????service????????????super.service()????