见如下文档:
http://www.itfuture.org/show.jsp?cid=146
一定要给分呀!
以后有问题可以到
http://www.itfuture.org/liuy
上提问有问必答!!
http://www.itfuture.org/show.jsp?cid=146
一定要给分呀!
以后有问题可以到
http://www.itfuture.org/liuy
上提问有问必答!!
解决方案 »
- oracle是否支持jbmp的*.hbm.xml自动建表
- struts 2 url传递中文参数乱码问题!急
- 关于javascript语言和WEB开发的菜鸟问题,高手请进!!
- 一个关于动态网站静态化的问题
- 用<c:out /> 能显示 〈% %〉 定义的变量吗
- 哪位大侠有SmartUpload上传工具,发一份给我...我上网找不到......谢谢先....
- 一个全新的自定义网络收藏夹,是否能够取得成功?
- 怎样获取年月日显示的下拉菜单 所显示的日期 最后使其成为一个Date类型的数据?
- applet 可以用鼠标画图,并存储到数据库中吗?
- 我看了一本JSP的书感觉很难阿!是不是书说的不好还是我的水平不够阿?
- dwr取页面数据问题。
- 请问,如何实自动选择不同的网络打印机
* This client send 1 byte 1000 times.
*/
import java.io.*;
import java.net.*;/**
* @author Chen Jay
*/
public class TCPClient { public static void main(String[] args) {
// TODO Auto-generated method stub
Socket client;
int count = 0;
long start;
long end;
try {
if (args.length != 2) {
System.out.println("Usage: java TCPClient <host> [port]");
return;
}
start = System.currentTimeMillis();
while (count < 1000) {
client = new Socket(args[0], Integer.parseInt(args[1]));
DataOutputStream out = new DataOutputStream(client
.getOutputStream());
client.getInputStream();
out.write("a".getBytes());
client.close();
count++;
}
end = System.currentTimeMillis();
System.out.println("One loops cost:"
+ (double) ((end - start) / 1000) + "ms");
} catch (UnknownHostException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}}
import javax.ejb.*;
import java.net.*;
import java.io.*;public class HTMLReaderBean implements SessionBean {
public StringBuffer getContents() throws HTTPResponseException { Context context;
URL url;
StringBuffer buffer;
String line;
int responseCode;
HttpURLConnection connection;
InputStream input;
BufferedReader dataInput;
try {
context = new InitialContext();
url = (URL)context.lookup("java:comp/env/url/MyURL");
connection = (HttpURLConnection)url.openConnection();
responseCode = connection.getResponseCode();
} catch (Exception ex) {
throw new EJBException(ex.getMessage());
} if (responseCode != HttpURLConnection.HTTP_OK) {
throw new HTTPResponseException("HTTP response code: " +
String.valueOf(responseCode));
} try {
buffer = new StringBuffer();
input = connection.getInputStream();
dataInput = new BufferedReader(new InputStreamReader(input));
while ((line = dataInput.readLine()) != null) {
buffer.append(line);
buffer.append('\n');
}
} catch (Exception ex) {
throw new EJBException(ex.getMessage());
} return buffer; } // getContents() public HTMLReaderBean() {}
public void ejbCreate() {}
public void ejbRemove() {}
public void ejbActivate() {}
public void ejbPassivate() {}
public void setSessionContext(SessionContext sc) {}}
URL url = new URL("http://www.abc.com/abc.html");
URLConnection conn = url.openConnection();
InputStream inStream = conn.getInputStream();FileOutputStream fs = new FileOutputStream(outputFilename);
byte[] buffer = new byte[1024];
int length=0;
int byteread = 0;
int bytesum = 0;
while ((byteread = inStream.read(buffer)) != -1) {
bytesum += byteread;
fs.write(buffer, 0, byteread);
}
fs.close();
uc.setConnectTimeout(10000);
uc.setDoOutput(true);
InputStream in = new BufferedInputStream(uc.getInputStream());
Reader rd = new InputStreamReader(in);
int c = 0;
StringBuffer temp = new StringBuffer();
while ((c = rd.read()) != -1) {
temp.append((char) c);
}
in.close();
strHtml = temp.toString(); //strHtml请求网页代码
如下: <script type="text/javascript">var xmlHttp;function createXMLHttpRequest() { if (window.ActiveXObject) { xmlHttp = new ActiveXObject("Microsoft.XMLHTTP"); } else if (window.XMLHttpRequest) { xmlHttp = new XMLHttpRequest(); }}function startRequest() {
var name= document.bianji.name.value;
createXMLHttpRequest();
xmlHttp.open("GET", "./newmessage.html", true);
xmlHttp.setRequestHeader("Content-Type","GBK");
xmlHttp.onreadystatechange = handleStateChange;
xmlHttp.send(null);
xmlhttp.setRequestHeader("If-Modified-Since","0");
}
function handleStateChange() { if(xmlHttp.readyState == 4) {
if(xmlHttp.status == 200) {
document.bianji.message.value = xmlHttp.responseText;
} }}</script>
<form action="类名" name="bianji" method="POST">
<table width=800>
<tr>
<td> <input type="hidden" name="message" value=""/>
<input type="submit" value="提交 " onclick="startRequest();"/>
</td>
</tr>
</table>
</form>