请教J2ME中用HTTP通信的问题。

wabc 2003-07-19 04:42:17
如果服务器端用JSP,那么如何设置其编码类型,才能正确接收手机发来的中文信息?
...全文
20 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
flagfly 2003-11-12
  • 打赏
  • 举报
回复
呵呵,这两天讨论http连接的一下子多了。
西门子gb2312,motorola是iso10646,其他就不知道了
skygui 2003-11-11
  • 打赏
  • 举报
回复
我写了一个HttpConnection的连接测试,使用388c手机无法正确使用,请指教
private String getHttpConnection(String url) throws IOException
{

HttpConnection hc =null;
DataInputStream is=null; // hc.openInputStream();
StringBuffer str = new StringBuffer();
try
{
hc =(HttpConnection) Connector.open(url);
is = new DataInputStream(hc.openDataInputStream());

int ch;
while ((ch=is.read())!=-1)
{
str.append((char) ch);
}
}
catch(Exception e)
{
e.printStackTrace();
str.append("open Error");
}
finally
{
try
{
if (is!=null) is.close();
if (hc!=null) hc.close();
}
catch(IOException ioe)
{
ioe.printStackTrace();
str.append("close Error");
}
}
return str.toString();
}

在模拟器无法取得数据,在真机上也无法取得数据。
真机上[JAVA应用]-[设置]-[默认连接]-CMWAP和CMNET都测试过,依然无法取得数据
有些没有数据返回,有些返回的数据为<html><head><title>Error</title></head><body>The parameter is incorrect.</body></html>
url="www.abkk.com"返回上述回应
url="www.yahoo.com"则没有返回,
为什么会这样?
iceeyer 2003-09-02
  • 打赏
  • 举报
回复
同意 我做过类似的东西 用readUTF和writeUTF就行了
rexwang 2003-09-01
  • 打赏
  • 举报
回复
同意上述观点.
网络咖啡 2003-09-01
  • 打赏
  • 举报
回复
http://www.csdn.net/develop/Read_Article.asp?Id=19849
miaoliujun 2003-09-01
  • 打赏
  • 举报
回复
在服务器中的数据流中,你将其writeUTF,然后到手机端,你再readUTF。这样就行了。
你可以在这里搜一下,有很多的
手机支持UTF-8
mercuryking 2003-09-01
  • 打赏
  • 举报
回复
不明白,但帮你顶一下。
bigporcupine 2003-08-31
  • 打赏
  • 举报
回复
UTF8
wabc 2003-07-19
  • 打赏
  • 举报
回复
只要两方面设置相同的编码类型即可。
但不知道一般手机都支持那些编码,那些编码是所有手机都必须支持的?

13,100

社区成员

发帖
与我相关
我的任务
社区描述
Java J2ME
社区管理员
  • J2ME社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧