我是个java初学者最近一直在学applet
想让applet可以和asp通信,我看了网上的一些applet通信的资料,都特少而且重复。我想通过url带参数的方法发给asp,例如:?content=123,asp端request(“content”)。但是我现在applet可以读取编译好的asp参数,但是不能发送参数到asp,我的代码如下,希望各位高人能给解决一下,我这个问题在SUN社区还有很多QQ群里都问了,很多人都说不会或者不看applet包括我老师也是,他们都觉得applet的商业价值不大而且麻烦,但是我觉得学习就应该深入学学,现在在论坛上很流行的applet+ASP制作的涂鸦版就是日本人做的applet我觉得他们能用applet制作出这么流行的东西而我们国内连个仿照的都没实在有点以外。
顺便在说下~日本人写的applet用的方法不是我这个,我看不懂,asp端是中国人写的用ADO来存储数据的。我不知道这里送分多少合适我有100分可以都送给能解决的高人
asp代码:<%content=request("content")
bb=2323
response.write "&&content="&content&"&bb="&bb%>
applet代码:
void sendButton_actionPerformed(ActionEvent e) {
String content=messageField.getText();
try{
String surl="http://localhost/bbs/code/chat.asp?"+URLEncoder.encode("content") + "=" +
URLEncoder.encode(content);
URL url = new URL(surl);
HttpURLConnection conn = (HttpURLConnection)url.openConnection();
conn.setDoOutput(true);
conn.setUseCaches(false);
conn.connect();
// POST the request data (html form encoded)
PrintStream out = new PrintStream(conn.getOutputStream());
out.println(url);out.close();
//HttpURLConnection httpConnection = (HttpURLConnection)url.openConnection ();
//httpConnection.connect();
//收
String content2;
surl2="http://localhost/bbs/code/chat.asp" ;
URL url2 = new URL(surl2);
URLConnection conn2 = url2.openConnection();
InputStreamReader reader=new InputStreamReader(conn2.getInputStream ());
BufferedReader in=new BufferedReader(reader);
String message;
message=in.readLine();
jTextArea1.insert("33:"+message+"\n",0);}
catch(IOException e1){
System.err.println ("IOException");
e1.printStackTrace (System.err);
showStatus(e1.toString ());
}
jTextArea1.insert("cc:"+content+"\n",0);
}
}applet全部代码:http://gceclub.sun.com.cn/NASApp/sme/jive/thread.jsp?forum=9&thread=10329