Ok, I changed my code just a little bit and realized I needed https://
instead of http:// that was in my code. I am now getting a SSL error
after doing that.
[INFO] HttpMethodDirector - I/O exception (javax.net.ssl.SSLException)
caught when processing request: The certificate container *SYYSTEM could
not be accessed.
[INFO] HttpMethodDirector - Retrying request
[INFO] HttpMethodDirector - I/O exception (javax.net.ssl.SSLException)
caught when processing request: The certificate container *SYYSTEM could
not be accessed.
[INFO] HttpMethodDirector - Retrying request
[INFO] HttpMethodDirector - I/O exception (javax.net.ssl.SSLException)
caught when processing request: The certificate container *SYYSTEM could
not be accessed.
[INFO] HttpMethodDirector - Retrying request
javax.net.ssl.SSLException: The certificate container *SYSTEM could not be
accessed.
java/lang/Throwable.<init>(Ljava/lang/String;)V+4
(Throwable.java:85)
java/lang/Exception.<init>(Ljava/lang/String;)V+1
(Exception.java:33)
java/io/IOException.<init>(Ljava/lang/String;)V+1
(IOException.java:38)
javax/net/ssl/SSLException.<init>(Ljava/lang/String;)V+1
(SSLException.java:43)
com/ibm/as400/ibmonly/net/ssl/AuthContext.access$000(Lcom/ibm/as400/ibmonly/net/ssl/AuthContext;Ljava/lang/String;Ljava/lang/
String;Ljava/lang/String;)V+1 (AuthContext.java:73)
com/ibm/as400/ibmonly/net/ssl/AuthContext$2.run()Ljava/lang/Object;+44
(AuthContext.java:119)
com/ibm/as400/ibmonly/net/ssl/AuthContext.<init>()V+12
(AuthContext.java:87)
com/ibm/as400/ibmonly/net/ssl/AuthContext.getDefault()Lcom/ibm/as400/ibmonly/net/ssl/AuthContext;+6
(AuthContext.java:168)
com/ibm/as400/ibmonly/net/ssl/SSLSocketFactoryImpl.<init>()V+4
(SSLSocketFactoryImpl.java:70)
java/lang/Class.newInstance()Ljava/lang/Object;+14 (Class.java:238)
javax/net/ssl/SSLSocketFactory.getDefault()Ljavax/net/SocketFactory;+127
(SSLSocketFactory.java:97)
javax/net/ssl/SSLSocketFactory.getDefault()Ljavax/net/SocketFactory;+127
(SSLSocketFactory.java:97)
org/apache/commons/httpclient/protocol/SSLProtocolSocketFactory.createSocket(Ljava/lang/String;ILjava/net/InetAddress;I)Ljava
/net/Socket;+0 (SSLProtocolSocketFactory.java:82)
org/apache/commons/httpclient/protocol/SSLProtocolSocketFactory.createSocket(Ljava/lang/String;ILjava/net/InetAddress;ILorg/a
pache/commons/httpclient/params/HttpConnectionParams;)Ljava/net/Socket;+33
(SSLProtocolSocketFactory.java:127)
org/apache/commons/httpclient/HttpConnection.open()V+184
(HttpConnection.java:707)
org/apache/commons/httpclient/HttpMethodDirector.executeWithRetry(Lorg/apache/commons/httpclient/HttpMethod;)V+83
(HttpMethodDirector.java:387)
org/apache/commons/httpclient/HttpMethodDirector.executeMethod(Lorg/apache/commons/httpclient/HttpMethod;)V+288
(HttpMethodDirector.java:171)
org/apache/commons/httpclient/HttpClient.executeMethod(Lorg/apache/commons/httpclient/HostConfiguration;Lorg/apache/commons/ht
tpclient/HttpMethod;Lorg/apache/commons/httpclient/HttpState;)I+114
(HttpClient.java:397)
org/apache/commons/httpclient/HttpClient.executeMethod(Lorg/apache/commons/httpclient/HttpMethod;)I+14
(HttpClient.java:323)
PolicyServlet.doPost(Ljavax/servlet/http/HttpServletRequest;Ljavax/servlet/http/HttpServletResponse;)V+871
(PolicyServlet.java:144)
javax/servlet/http/HttpServlet.service(Ljavax/servlet/http/HttpServletRequest;Ljavax/servlet/http/HttpServletResponse;)V+136
(HttpServlet.java:760)
javax/servlet/http/HttpServlet.service(Ljavax/servlet/ServletRequest;Ljavax/servlet/ServletResponse;)V+25
(HttpServlet.java:8553)
org/apache/tomcat/core/ServletWrapper.doService(Lorg/apache/tomcat/core/Request;Lorg/apache/tomcat/core/Response;)V+66
(ServletWrapper.java:405)
org/apache/tomcat/core/Handler.service(Lorg/apache/tomcat/core/Request;Lorg/apache/tomcat/core/Response;)V+198
(Handler.java:287)
org/apache/tomcat/core/ServletWrapper.service(Lorg/apache/tomcat/core/Request;Lorg/apache/tomcat/core/Response;)V+139
(ServletWrapper.java:372)
org/apache/tomcat/core/ContextManager.internalService(Lorg/apache/tomcat/core/Request;Lorg/apache/tomcat/core/Response;)V+260
(ContextManager.java:806)
org/apache/tomcat/core/ContextManager.service(Lorg/apache/tomcat/core/Request;Lorg/apache/tomcat/core/Response;)V+15
(ContextManager.java:752)
org/apache/tomcat/service/connector/JNIConnectionHandler.processConnection(JJ)V+253
(JNIConnectionHandler.java:186)
org/apache/tomcat/service/JNIEndpoint.service(JJ)I+13
(JNIEndpoint.java:176)
This is my code:
//Create an instance of HttpClient.
HttpClient client = new HttpClient();
// Create a method instance.
PostMethod post = new PostMethod(
"
https://www.url.com/app/cgi-bin/test/nav.mac/service_link");
NameValuePair[] data = {
new NameValuePair("agent_id", username),
new NameValuePair("password", pwd),
new NameValuePair("poltyp", type),
new NameValuePair("polno", policy)
};
post.setRequestBody(data);
try {
client.executeMethod(post);
if (post.getStatusCode() == HttpStatus.
SC_OK) {
System.out
.println(post.getResponseBodyAsString());
} else {
System.out.println("Unexpected failure: " +
post.getStatusLine().toString());
}
}
catch(HttpException e) {
e.printStackTrace();
}
catch(IOException e) {
e.printStackTrace();
}
finally {
post.releaseConnection();
}
I also checked the following directories and they have *RX access for
QTMHHTP1 or Public
/
/QIBM
/QIBM/UserData
/QIBM/UserData/ICSS
/QIBM/UserData/ICSS/Cert
/QIBM/UserData/ICSS/Cert/Server
and these directories have *RW for QTMHHTP1
/QIBM/UserData/ICSS/Cert/Server/DEFAULT.KDB
/QIBM/UserData/ICSS/Cert/Server/DEFAULT.RDB
Any help is greatly appreciated.
Thanks
Kara
message: 1
date: Thu, 10 Apr 2008 14:29:20 -0700
from: "Clapham, Paul" <pclapham@xxxxxxxxxxxxx>
subject: RE: HTTPClient help
Well, I looked in the API documentation of the releaseConnection()
method and it says:
"After this method is called, getResponseBodyAsStream() will return
null, and getResponseBody() and getResponseBodyAsString() may return
null."
The documentation doesn't say why you would want to use that method, and
I don't know enough about HTTP to say what it's supposed to achieve, but
I would take out the line that calls that method. I don't use it in my
code that also uses Apache HttpClient.
Regards
PC2
-----Original Message-----
From: java400-l-bounces@xxxxxxxxxxxx
[mailto:java400-l-bounces@xxxxxxxxxxxx] On Behalf Of Kara Burkhalter
Sent: April 10, 2008 05:46
To: java400-l@xxxxxxxxxxxx
Subject: HTTPClient help
I am trying to redirect to a URL from a servlet using POST. I get no
error messages but my page doesn't go anywhere. My print statement at
the end prints "ResponseBody = null". What am I doing wrong? This is my
code that I have (note I have removed actual URL for security
reasons)....
//Create an instance of HttpClient.
HttpClient client = new HttpClient();
// Create a method instance.
PostMethod post = new PostMethod("
https://URL");
NameValuePair[] data = {
new NameValuePair("agent_id", username),
new NameValuePair("password", pwd),
new NameValuePair("poltyp", type),
new NameValuePair("polno", policy)
};
post.setRequestBody(data);
try {
client.executeMethod(post);
post.releaseConnection();
String in =
post.getResponseBodyAsString();
System.out.println("ResponseBody = " +
in);
}
catch(HttpException e) {
e.printStackTrace();
}
catch(IOException e) {
e.printStackTrace();
}
Thank you for your help!
Kara
This message may contain confidential or proprietary information and is
intended only for the person(s) to whom it is addressed. Any use,
distribution, copying or disclosure of confidential information by any
other person is strictly prohibited. If you have received this message in
error, please notify the e-mail sender immediately, and delete the
original message without making a copy. For information on the UW
Foundation's privacy policy, please visit:
UW Foundation Privacy Policy
As an Amazon Associate we earn from qualifying purchases.