如题...
我想在Servlet中获取手机(客户端发过来的数据),下面的代码是我做的普通的java类,已经实现了接受手机端数据并保存道本地的功能,
现在我想把这个移植到Servlet上面,请教大虾该怎么做??
急急急..
import java.net.*;
import java.io.*;
public class Server {
public static void main(String[] args) throws Exception {
ServerSocket ss = new ServerSocket(6666);
int b=0;
while(true) {
Socket s = ss.accept();
InputStream is = s.getInputStream();
OutputStream out = new FileOutputStream("e:/2.txt");
 while((b=is.read())!=-1){
      out.write(b);
 }
is.close();
out.close();
s.close();
}
}
}

解决方案 »

  1.   

    凌晨三点了,(~ o ~)~zZ..睡了,但愿明天起床时能找到答案........拜托了...
      

  2.   

    servlet 是已经经过处理的 socket 数据.
    你可以把 socket 传来的字符串用 date=XXXXX 的形式传过来.
    然后再 servlet 里 getParameter().
      

  3.   

    使用J2ME中的SocketConnectionSocketConnection sc = (SocketConnection)
                             Connector.open("socket://host.com:79");
       sc.setSocketOption(SocketConnection.LINGER, 5);   InputStream is  = sc.openInputStream();
       OutputStream os = sc.openOutputStream();   os.write("\r\n".getBytes());
       int ch = 0;
       while(ch != -1) {
           ch = is.read();
       }   is.close();
       os.close();
       sc.close();
      

  4.   

    InputStream is  = request.getInputStream();