You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Jeremy Pierson <jp...@isolvetechnologies.com> on 2002/06/18 05:50:54 UTC

Apache Tomcat/4.0.3 - HTTP Status 302 - Moved Temporarily

Connecting to this particular website via SSL (HTTPS) with a browser such as
IE or Netscape, everything works fine.  Attempting to connect to this same
site (any page on the site) via a servlet from another site (though this
other site is a virtual host on the same machine ­ diff. IP addresses too) I
get the HTTP 302 status response for all requests!

Other notes:  this code works fine connecting to other HTTPS servers as
well!  Is this a Tomcat configuration problem on the HTTPS host, or a
problem with the client HTTPS request?

Any ideas here?  I've been racking my brain for 12 hours now.  Thanks!

-jeremy-



Here¹s a sample of the servlet code that makes the HTTPS request:


URL url = null;
HttpsURLConnection con = null;
PrintWriter pout = null;
BufferedReader pin = null;
try {
    url = new URL("https://secure.server.com/index.jsp");
    System.out.println("Connecting to '" + url.toString() + "'...");
    con = (HttpsURLConnection)url.openConnection();
    con.setFollowRedirects(false);
    con.setHostnameVerifier(
            new HostnameVerifier()
            {
            public boolean verify( String urlHost, SSLSession ssls ){
            if( !urlHost.equals(ssls.getPeerHost())){
            System.out.println("certificate <" + ssls.getPeerHost() +
            "> does not match host <" + urlHost + "> but " +
            "continuing anyway");
            }
            return true;
            }} );
    con.setDoOutput(true);
    con.setDoInput(true);
    con.setUseCaches(false);
    con.setDefaultUseCaches(false);
    
con.setRequestProperty("Content-Type","application/x-www-form-urlencoded");
    ((HttpURLConnection)con).setRequestMethod("POST");
    StringBuffer params = new StringBuffer();
    params.append("auth_code=");
    params.append(URLEncoder.encode(auth_code, "UTF-8"));
    pout = new PrintWriter(con.getOutputStream());
    pout.println(params.toString());
    pout.flush();
    pout.close();

... Etc ...


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>