1、
//向tomcat发送信息
Socket s = new Socket("127.0.0.1",8080);
PrintWriter pw = new PrintWriter(new OutPutStreamWriter(s.getOutputStream()));
pw.println("GET / HTTP/1.1");
pw.println("Host:");
pw.println("Content-Type:text/html")
pw.flush()
//接受返回的内容
BufferedRead br = new BufferedReader(new InputStreamReader(s.getInputStream()));
String str = "";
while((str=br.readLine())!=null) {
System.out.Println(str);
};
br.close();
pw.close();
s.close();
2、
结构
WEB-INF
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_3_0.xsd"
version="3.0"
metadata-complete="true">
</Web-app>