关于jetty的一个问题

ghostdom 发布于 2012/05/11 14:39
阅读 359
收藏 0

各位好,最近用jetty8.1.3发布了一个http接口,代码如下。对方往我这个接口上推信息,但是发现对方推送过来的成功率比较低,互相ping过服务器,网络应该算ok。帮我看看是代码问题还是?

 没人任何配置,就引用了jetty jar包跟下面这个类发布的。

 

package com.gaotime.sms.hongshu;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.math.NumberUtils;
import org.apache.log4j.Logger;
import org.dom4j.Document;
import org.dom4j.DocumentHelper;
import org.dom4j.Element;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.servlet.ServletContextHandler;
import org.eclipse.jetty.servlet.ServletHolder;

import com.gaotime.sms.Message;
import com.gaotime.sms.SMSGateWay;
import com.gaotime.sms.SMSReply;
import com.gaotime.sms.SMSReport;
import com.gaotime.sms.socketprotocol.ReportMessage;
import com.sms.util.Util;

public class HongshuService {
 private static final Logger log = Logger.getLogger(HongshuService.class);

 public HongshuService(int port) {
  try {
   Server server = new Server(port);
   ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
   context.setContextPath("/");
   server.setHandler(context);
   context.addServlet(new ServletHolder(new ReportServlet()), "/report");

   server.start();
  } catch (Exception e) {
   log.error("", e);
  }
 }
}

class ReportServlet extends HttpServlet {
 private static final Logger log = Logger.getLogger(ReportServlet.class);
 private PrintWriter out;

 protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
  try {
   out = response.getWriter();
   String str = IOUtils.toString(request.getInputStream());
   if (str != null && str.length() > 0) {
    log.info("report str = " + str);
   //do something

   }
   out.print("0");
  } catch (Exception e) {
   log.error("", e);
   out.print("9");
  }
 }

 protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
  this.doGet(req, resp);
 }

}
}

加载中
0
ghostdom
ghostdom
@红薯 ,老大  帮忙看看啊
0
ghostdom
ghostdom
顶上去。。。
返回顶部
顶部