2012-12-15 120 views
1

我在Java運行時使用通道API。我映射到/ _ah/channel/connected的servlet似乎沒有運行。我正在創建一個通道,傳遞令牌並在服務器上打開它。這工作正常。我在日誌中看到/ _ah/channel /連接的呼叫,但是沒有出現日誌消息,代碼似乎也沒有運行。下面是我的代碼和web.xmlAppengine Channel API presence _ah/channel/connected not working

ChannelConnectedServlet.java:

public class ChannelConnectedServlet extends HttpServlet{ 
    private static final Logger logger = Logger.getLogger(ChannelConnectedServlet.class 
      .getName()); 

    private void process(HttpServletRequest req, HttpServletResponse resp) throws IOException { 
     logger.log(Level.WARNING,"test"); 
     //do stuff here 
    } 

    public void doPost(HttpServletRequest req, HttpServletResponse resp) 
        throws IOException, ServletException {   
     logger.log(Level.WARNING,"Channel connected!"); 
     process(req, resp); 
    } 
} 

的web.xml:

<servlet-mapping> 
    <servlet-name>ChannelConnected</servlet-name> 
    <url-pattern>/_ah/channel/connected</url-pattern> 
</servlet-mapping> 

<servlet> 
    <servlet-name>ChannelConnected</servlet-name> 
    <servlet-class>com.myapp.server.channel.ChannelConnectedServlet</servlet-class> 
</servlet> 

同樣的行爲將發生在斷開連接請求。幫幫我!!!

回答

1

在web.xml此條應包括 「/」 在URL的結尾,如:

<servlet-mapping> 
<servlet-name>ChannelConnected</servlet-name> 
<url-pattern>/_ah/channel/connected/</url-pattern> 

現在的作品。