WAP之家:为您提供最全最新的WAP技术,CP.SP.3G等行业资讯。 WAP之家交流论坛全新开放 点击进入>>
WAP资讯 | 3G动态 | SP动态 | 运营商动态 | 内容商动态 | 制造商动态 | 论坛讨论>> 每次自动访问
WAP技术 | WAP源码 | 手机编程 | 手机源码 | 无线技术 | J2ME技术 | 手机软件 添加到收藏夹
IVR技术 | SP资料 | SMS MMS技术 | 商业方案 | IVR下载 | 书籍教程 | 工具软件 语言:繁體中文

WAP之家技术文章J2ME技术进阶教程在无线J2ME设备上实现超文本传输协议

在无线J2ME设备上实现超文本传输协议
作者:cherio  来源:转载  发布时间:2005-7-15 15:01:41
pConnection )Connector.open( url, Connector.READ_WRITE );

//设置请求方法为POST
hcon.setRequestMethod( HttpConnection.POST );

// 取得发送请求字符串的DataOutputStream
dos = hcon.openDataOutputStream();
byte[] request_body = requeststring.getBytes();

// 发送请求字符串到服务器
for( int i = 0; i < request_body.length; i++ ) {;
dos.writeByte( request_body[i] );
};//结束 for( int i = 0; i < request_body.length; i++ )

// 取得做为接收服务器响应的DataInputStream dis = new DataInputStream( hcon.openInputStream() );

// 从服务器上取回响应
int ch;
while( ( ch = dis.read() ) != -1 ) {;
responseMessage.append( (char)ch );
};//结束while( ( ch = dis.read() ) != -1 ) {;
};
catch( Exception e )
{;
e.printStackTrace();
responseMessage.append( "ERROR" );
}; finally {;
// 释放输入输出流和HTTP连接
try {;
if( hcon != null ) hcon.close();
if( dis != null ) dis.close();
if( dos != null ) dos.close();
}; catch ( IOException ioe ) {;
ioe.printStackTrace();
};//结束try/catch };//结束try/catch/finally
return responseMessage.toString();
};//结束sendHttpPost( String )

public void pauseApp() {;
};//结束pauseApp()

public void destroyApp( boolean unconditional ) {;
myDisplay = null;
requestScreen = null;
requestField = null;
resultScreen = null;
resultField = null;
};//结束 destroyApp( boolean )
};//结束HttpMidlet

上一页  [1] [2] [3] 

[] [返回上一页] [打 印]
文章评论

用户名: 查看更多评论

分 值:100分 85分 70分 55分 40分 25分 10分 0分

内 容:

         (注“”为必填内容。) 验证码: 验证码,看不清楚?请点击刷新验证码