就是一些滿炫目的JavaScript程式:
Java Script 經典封裝
(文源自於 PCOnline)拿來套用還滿方便的,站在巨人的肩膀上....
(hssfCell1.getStyle()==hssfCell2.getStyle())
(hssfCell1.getStyle().equals(hssfCell2.getStyle()))
(hssfCell1.getStyle().getIndex()==hssfCell2.getStyle().getIndex())
|
response.setDateHeader("Expires", 0);
response.setHeader("Pragma", "public");
response.setHeader("Cache-Control", "max-age=0");
|
response.setDateHeader("Expires", 0);
response.setHeader("Pragma", "public");
response.setHeader("Cache-Control", "max-age=0");
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.methods.GetMethod;
public class test{
public static void main(String[] args)
{
try{
HttpClient client=new HttpClient();
GetMethod method=new GetMethod("http://www.hinet.net");
int resultCode=client.executeMethod(method);
if(resultCode==200)
System.out.println(method.getResponseAsString());
}catch(Exception e)
{}
}
}
HttpClient client=new HttpClient();
client.getParams().setParameter("http.useragent", "java browser");
import java.io.FileOutputStream;
import org.apache.commons.httpclient.HostConfiguration;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.URI;
import org.apache.commons.httpclient.methods.GetMethod;
import org.apache.commons.httpclient.protocol.Protocol;
public class test {
public static void main(String[] args) {
try {
HttpClient client=new HttpClient();
client.getParams().setParameter("http.useragent", "java browser");
GetMethod method=new GetMethod();
method.setURI(new URI("http://tw.yimg.com/i/tw/dictionary/masthead_logo.gif"));
HostConfiguration hostConfig=new HostConfiguration();
hostConfig.setHost("tw.yimg.com",null,80,Protocol.getProtocol("http"));
int result=client.executeMethod(hostConfig,method);
System.out.printf("result code=%d",result);
byte[] gif=method.getResponseBody();
FileOutputStream fos=new FileOutputStream("c:\\image.gif");
fos.write(gif);
fos.close();
} catch (Exception e) {
// TODO: handle exception
}
}
}
import java.io.BufferedOutputStream;
import java.io.FileOutputStream;
import java.io.InputStream;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager;
import org.apache.commons.httpclient.methods.GetMethod;
import org.apache.commons.httpclient.params.HttpConnectionManagerParams;
import org.apache.commons.httpclient.params.HttpConnectionParams;
public class MultiThread extends Thread {
private HttpClient client;
private GetMethod method;
public MultiThread(HttpClient client,GetMethod method)
{
this.client=client;
this.method=method;
}
public static void main(String[] args) {
MultiThreadedHttpConnectionManager mcm=new MultiThreadedHttpConnectionManager();
HttpConnectionManagerParams params=new HttpConnectionManagerParams();
params.setDefaultMaxConnectionsPerHost(10);
mcm.setParams(params);
HttpClient client=new HttpClient(mcm);
GetMethod method1=new GetMethod("http://www.sun.com/images/l2/l2_phone_pda.gif");
GetMethod method2=new GetMethod("http://www.sun.com/images/l2/l2_swingap.gif");
GetMethod method3=new GetMethod("http://java.sun.com/javase/images/dukejdk6_100x88.gif");
new MultiThread(client,method1).start();
new MultiThread(client,method2).start();
new MultiThread(client,method3).start();
}
@Override
public void run() {
try{
client.executeMethod(method);
String filePath="c:\\"+method.getURI().getName();
InputStream input=method.getResponseBodyAsStream();
BufferedOutputStream bos=new BufferedOutputStream(new FileOutputStream(filePath));
int data;
while((data=input.read())>=0)
bos.write(data);
input.close();
bos.close();
}catch(Exception e)
{
System.out.println(e);
}
}
}
import org.apache.commons.httpclient.*;
import org.apache.commons.httpclient.auth.*;
import org.apache.commons.httpclient.method.*;
public class authExam{
public static void main(String[] args) throws Exception{
HttpClient client=new HttpClient();
HostConfiguration host=client.getHostConfiguration();
host.setHost(new URI("http://localhost:8080",true));
GetMethod method=new GetMethod("protectedArea/protect.jsp");
try{
int code=client.executeMethod(host,method);
if (code==HttpStatus.SC_UNAUTHORIZED)
{
Crenditals cred=new UsernamePasswordCrenditals("tomcat","tomcat");
AuthScope scope=new AuthScope(host.getHost(),host.getPort());
client.getState().setCrentials(scope,cred);
client.executeMethod(host,method);
}
}catch(Exception e){}
}
}
authentication 範例2
public class authExam2{
public static void main(String args[]) throws Exception
{
HttpClient client=new HttpClient();
HostConfiguration host=client.getHostConfiguration();
host.setHost(new URI("http://localhost:8080",true));
Credentials cre=new UsernamePasswordCredential("tomcat","tomcat");
AuthoScope scope=new AuthScope(host.getHost(),host.getPort());
client.getState().setCredentials(scope,cre);
try{
client.executeMethod(new GetMethod("http://localhost/protectedArea");)
}
catch(Exception e){}
}
}