Formula One for Java ,提供了JAVA调用Excel的接口,该问题的重点在于,SSL中好像无法调出嵌入在HTML中的其他文件格式(如:"application/vnd.ms-excel");
If you are running a standalone application, or want to use SSL over your own sockets and avoid using URL or URLConnection, then you need to obtain an implementation of the Java Secure Socket Extension, or JSSE. Sun provides a reference implementation of JSSE, along with sample programs, which you can download from http://java.sun.com/products/jsse/. It comes in both a "domestic version" (US/Canada) and an "export version" (all other countries).
import javax.net.ssl.*; import java.io.*; import java.net.*; import java.security.*;public class SSLSocketClient { public static void main(String args[]) throws Exception { String urlString = (args.length == 1) ? args[0] : "http://www.verisign.com/index.html"; URL url = new URL(urlString); Security.addProvider( new com.sun.net.ssl.internal.ssl.Provider()); SSLSocketFactory factory = (SSLSocketFactory)SSLSocketFactory.getDefault(); SSLSocket socket = (SSLSocket)factory.createSocket(url.getHost(), 443); PrintWriter out = new PrintWriter( new OutputStreamWriter( socket.getOutputStream())); out.println("GET " + urlString + " HTTP/1.1"); out.println(); out.flush(); BufferedReader in = new BufferedReader( new InputStreamReader( socket.getInputStream())); String line; while ((line = in.readLine()) != null) { System.out.println(line); } out.close(); in.close(); } }
My problem is, I can not download a html page with content type "application/vnd.ms-excel" generated by a serverlet on IBM Websphere with SSL option turned on. The html page, which generate an excel page on client browser works well when SSL turned off, but failed when on. I have heard of things like this happend elsewhere and I have no idea why. I will be very grateful if you may help me or ask me more details about my question, by email or telephone. [email protected] (010)66069966-8838
import java.io.*;
import java.net.*;
import java.security.*;public class SSLSocketClient { public static void main(String args[]) throws Exception { String urlString = (args.length == 1) ?
args[0] : "http://www.verisign.com/index.html";
URL url = new URL(urlString); Security.addProvider(
new com.sun.net.ssl.internal.ssl.Provider()); SSLSocketFactory factory =
(SSLSocketFactory)SSLSocketFactory.getDefault();
SSLSocket socket =
(SSLSocket)factory.createSocket(url.getHost(), 443); PrintWriter out = new PrintWriter(
new OutputStreamWriter(
socket.getOutputStream()));
out.println("GET " + urlString + " HTTP/1.1");
out.println();
out.flush(); BufferedReader in = new BufferedReader(
new InputStreamReader(
socket.getInputStream())); String line; while ((line = in.readLine()) != null) {
System.out.println(line);
} out.close();
in.close();
}
}
The html page, which generate an excel page on client browser works well when SSL turned off, but failed when on.
I have heard of things like this happend elsewhere and I have no idea why.
I will be very grateful if you may help me or ask me more details about my question, by email or telephone. [email protected] (010)66069966-8838
public void Paint()
{
try
{
//SSL访问时,加这一句就出错:
setContentType("application/vnd.ms-excel");
}
catch(Throwable e)
{
System.out.println(e.getMessage());
}
}