注册 登录
编程论坛 J2EE论坛

jsp中的通信

chenjiang001 发布于 2007-04-23 12:15, 627 次点击

<html>
<head>
<title>map</title>
</head>
<body>
<%
String getvalue;
getvalue=request.getParameter("select");
这块怎样用java下面的类实现发送字符串getvalue?
不知道这块怎么写?

%>

</body>
</html>

import java.io.*;
import java.net.*;

public class Client
{
public void SendData()
{
Socket clientSock=null;
try
{
clientSock=new Socket("127.0.0.1",10000);

if(clientSock!=null)
{
out.println("now,the state is connected!");
}

PrintWriter sockOutput= new PrintWriter(clientSock.getOutputStream());

sockOutput.println(getvalue);
sockOutput.flush();
}
catch(Exception e)
{
e.getStackTrace();
}
}

public static void main(String args[])
{
Client c=new Client();
c.SendData();
}
}

2 回复
#2
chenjiang0012007-04-23 17:50
这方面的东西实在不会
请教各位
#3
zhouhengbin2007-04-28 02:17
应该可以用上下文吧
定义个ServletContext xxx = getServletContext()
再将getselect绑定xxx.getsetAttribute("aaa",getcelect)
因为这样就可以共享
到时候调用aaa应该就可以了
我也是初学者!
1