1.启动tomcat服务器,即可读取tomcat首页内容
Socket socket =new Socket("127.0.0.1",8080);
boolean autoflush=true;
PrintWriter out =new PrintWriter(socket.getOutputStream(),autoflush);
BufferedReader in = new BufferedReader(new InputStreamReader(socket.getInputStream()));
out.println("GET /index.jsp HTTP/1.1");
out.println("Host: localhost:8080");
out.println("Connection:close");
out.println();
boolean loop = true ;
StringBuffer sb =new StringBuffer(8096);
while(loop){
if(in.ready()){
int i=0;
while(i!=-1){
i=in.read();
sb.append((char)i);
}
loop=false;
}
Thread.currentThread().sleep(50);
}
System.out.println(sb.toString());
socket.close();
2.Tomcat的日志记录器
Tomcat提供了3种日志记录器,其类分别是FileLogger、SystemErrorLogger和SystemOutLogger。这3个类都位于org.apache.catalina.logger包下,均集成了org.apache.catalina.logger.LoggerBase类。在Tomcat4中LoggerBase类实现了org.apache.catalina.Logger接口。在Tomcat5中,LoggerBase类还实现了Lifecycle接口和MBeanRegistration接口。
3.Bootstrap类启动采用了双亲委派机制实现由一个类来启动整个tomcat容器