如何在jsp页面中填充https GET responese

时间:2016-03-18 08:11:41

标签: java jsp

我是JAVA / JSP世界的新手,尝试在jsp页面中填充https GET响应,下注得到500错误。请帮忙解决这个问题。 HTTPS Get session在Rest客户端中正常工作。

    <!DOCTYPE html><%@

    page import="java.util.Date"                                       %><%@ 
    page import="java.net.*"                                           %><%@ 
    page import="java.io.*"                                            %><%@ 
    page import="java.util.HashMap"                                    %><%@ 
    page import="javax.net.ssl.HttpsURLConnection"                     %><%@ 
    page import="org.apache.commons.io.IOUtils"                        %><%@ 
    page contentType="text/html;charset=UTF-8" language="java"         %><% 

    String httpsURL = "https://localhost:8002/";
    URL myurl = new URL(httpsURL);
    HttpsURLConnection con = (HttpsURLConnection)myurl.openConnection();
    con.setRequestProperty("Accept", "*/*");
    InputStream is = con.getInputStream();
    String json        = IOUtils.toString(is, "UTF-8");

    %>

    <%=json%>

0 个答案:

没有答案