Java???HttpURLConnection??servlet???
???????????? ???????[ 2015/6/9 13:16:38 ] ???????????????
?????о????????????????????????????£???????ο???
??????????????servlet???
?????????????WEB-INF????????classes????С?lib????С?web.xml?????
??????д???servlet???????.class???????е?classes??????£??????helloServlet.class??
????1????web.xml??????
<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
version="2.5">
<servlet>
<servlet-name>HelloServlet</servlet-name>
<servlet-class>helloServlet</servlet-class><!-·????????????????classes?е?myclass???????myclass/helloServlet???????lib?е?.jar??????com.gis.arcgisengine.ServiceContext?????->
</servlet>
<servlet-mapping>
<servlet-name>HelloServlet</servlet-name>
<url-pattern>/hello</url-pattern><!-???url??????????????????helloServlet.class??????????/??????->
</servlet-mapping>
</web-app>
????2??helloServlet???????servlet??
import java.io.IOException;
import java.io.PrintWriter;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import javax.servlet.ServletException;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class helloServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
public helloServlet() {
super();
}
public void destroy() {
super.destroy(); // Just puts "destroy" string in log
// Put your code here
}
public void doGet(HttpServletRequest request?? HttpServletResponse response)
throws ServletException?? IOException {
doPost(request??response);
}
public void doPost(HttpServletRequest request?? HttpServletResponse response)
throws ServletException?? IOException {
//overwrite
String[] myName = null;
response.setContentType("application/octet-stream");
try {
ObjectInputStream ois = new ObjectInputStream(request.getInputStream());
Object obj = ois.readObject();//????????????????????????
ois.close();
myName = (String[])obj;
for(int i=0;i<myName.length;i++){
System.out.println(myName[i]);
}
} catch (Exception e) {
e.printStackTrace();
}
String name = request.getParameter("name");
ServletOutputStream out = response.getOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(out);
oos.writeObject(name);//д?????????????????ú?????
oos.close();
out.close();
/*String name = request.getParameter("name");
if(name != null){
name = new String(name.getBytes("ISO-8859-1")??"GB2312");
}else{
name = "????";
}
response.setContentType("text/html;charset=GB2312");
PrintWriter out = response.getWriter();
out.println("<HTML>");
out.println(" <HEAD><TITLE>A Servlet</TITLE></HEAD>");
out.println(" <BODY>");
out.println("<h1>"+name+":???</h1>");
out.println(" </BODY>");
out.println("</HTML>");
System.out.println(name);
out.flush();
out.close();*/
}
public void init() throws ServletException {
// Put your code here
}
}
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11