2011-07-11 34 views
0

我想从桌面应用程序发送一些数据,以谷歌AWT小服务程序
我目前在我的系统(本地主机)尝试这个,因为我已经安装了Eclipse插件
我发送数据这样在谷歌AWT的servlet读取数据的发送由客户端

URL url = new URL("http://localhost:8888/calendar"); 
URLConnection urlConnection = url.openConnection(); 
urlConnection.setDoOutput(true); 
PrintWriter out = new PrintWriter(urlConnection.getOutputStream()); 

String stringTosend = URLEncoder.encode(tf.getText(), "UTF-8"); 
out.write(stringTosend); 

和我的servlet是这样

public class CalendarServlet extends HttpServlet { 
    public void doPost(HttpServletRequest req, HttpServletResponse resp) 
      throws IOException { 
     resp.setContentType("text/plain"); 
     String input = req.getReader().readLine(); 
     resp.getWriter().println(input); 
    } 
} 

但是我又回到为NULL。

+0

什么是AWT的servlet? – keuleJ

回答

相关问题