當前位置: 首頁>>代碼示例>>Java>>正文


Java CometEvent類代碼示例

本文整理匯總了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.");
}
 
開發者ID:liaokailin,項目名稱:tomcat7,代碼行數:19,代碼來源:ChatServlet.java

示例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();
}
 
開發者ID:liaokailin,項目名稱:tomcat7,代碼行數:13,代碼來源:ChatServlet.java

示例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;
        }
    }
}
 
開發者ID:liaokailin,項目名稱:tomcat7,代碼行數:18,代碼來源:ChatServlet.java

示例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();
}
 
開發者ID:liaokailin,項目名稱:tomcat7,代碼行數:9,代碼來源:ChatServlet.java

示例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);
    }
}
 
開發者ID:nologic,項目名稱:nabs,代碼行數:14,代碼來源:ChatServlet.java

示例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();
    
}
 
開發者ID:nologic,項目名稱:nabs,代碼行數:14,代碼來源:ChatServlet.java

示例7: error

import org.apache.catalina.CometEvent; //導入依賴的package包/類
public void error(CometEvent event,HttpServletRequest request, HttpServletResponse response ){

    }
 
開發者ID:OPENDAP,項目名稱:olfs,代碼行數:4,代碼來源:ChatServlet.java


注:本文中的org.apache.catalina.CometEvent類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。