本文整理匯總了Java中org.apache.catalina.CometEvent類的典型用法代碼示例。如果您正苦於以下問題:Java CometEvent類的具體用法?Java CometEvent怎麽用?Java CometEvent使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
CometEvent類屬於org.apache.catalina包,在下文中一共展示了CometEvent類的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: begin
import org.apache.catalina.CometEvent; //導入依賴的package包/類
protected void begin(CometEvent event, HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException {
log("Begin for session: " + request.getSession(true).getId());
response.setContentType("text/html; charset=" + CHARSET);
PrintWriter writer = response.getWriter();
writer.println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">");
writer.println("<html><head><title>JSP Chat</title></head><body bgcolor=\"#FFFFFF\">");
writer.println("<div>Welcome to the chat. <a href='chat'>Click here to reload this window</a></div>");
writer.flush();
synchronized(connections) {
connections.add(response);
}
messageSender.send("Tomcat", request.getSession(true).getAttribute("nickname") + " joined the chat.");
}
示例2: end
import org.apache.catalina.CometEvent; //導入依賴的package包/類
protected void end(CometEvent event, HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException {
log("End for session: " + request.getSession(true).getId());
synchronized(connections) {
connections.remove(response);
}
PrintWriter writer = response.getWriter();
writer.println("</body></html>");
event.close();
}
示例3: read
import org.apache.catalina.CometEvent; //導入依賴的package包/類
protected void read(CometEvent event, HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException {
InputStream is = request.getInputStream();
byte[] buf = new byte[512];
while (is.available() > 0) {
log("Available: " + is.available());
int n = is.read(buf);
if (n > 0) {
log("Read " + n + " bytes: " + new String(buf, 0, n)
+ " for session: " + request.getSession(true).getId());
} else if (n < 0) {
log("End of file: " + n);
end(event, request, response);
return;
}
}
}
示例4: error
import org.apache.catalina.CometEvent; //導入依賴的package包/類
protected void error(CometEvent event, HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException {
log("Error for session: " + request.getSession(true).getId());
synchronized(connections) {
connections.remove(response);
}
event.close();
}
示例5: begin
import org.apache.catalina.CometEvent; //導入依賴的package包/類
protected void begin(CometEvent event, HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException {
log("Begin for session: " + request.getSession(true).getId());
PrintWriter writer = response.getWriter();
writer.println("<!doctype html public \"-//w3c//dtd html 4.0 transitional//en\">");
writer.println("<html><head><title>JSP Chat</title></head><body bgcolor=\"#FFFFFF\">");
writer.flush();
synchronized(connections) {
connections.add(response);
}
}
示例6: end
import org.apache.catalina.CometEvent; //導入依賴的package包/類
protected void end(CometEvent event, HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException {
log("End for session: " + request.getSession(true).getId());
synchronized(connections) {
connections.remove(response);
}
PrintWriter writer = response.getWriter();
writer.println("</body></html>");
event.close();
}
示例7: error
import org.apache.catalina.CometEvent; //導入依賴的package包/類
public void error(CometEvent event,HttpServletRequest request, HttpServletResponse response ){
}