Re: applet to j2ee with session handling
Hi, I wanted to do that but i didnt manage to get anywhere the session id as : - I have no clue how to access the cookie information from the applet (in J2SE there arent any Cookie class) - i find no other information the http headers and the url parameters... It looks like it s browser-dependant but i have been testing in several environment (linux, wds, ie nets...) and it all works the same : after a form authentication (simple html), the applet doesnt have to be authenticated if a connection is made through the normal java.net.URLConnection. The only way i see to get it is to ask the server to give it to us through java.net and request for example a JSP containing this simple tag: %= request.getSession().getID() % Reading in client side would be like : URLConnection conn = new URL(codebase, /mysessionid.jsp).openConnection(); DataInputStream ois = new DataInputStream(conn.getInputStream()); String mysessionid = ois.readUTF(); After reading this info, as you said Adrian, we just have to append it to the url of the HttpMethod from httpclient. String myuri = /myservlet; myuri += ;jsessionid= + mysessionid; // append GetMethod get = new GetMethod(myuri); // ..etc... It should work.. but is it the easiest solution ? - Original Message - From: Adrian Sutton [EMAIL PROTECTED] To: Commons HttpClient Project [EMAIL PROTECTED] Sent: Tuesday, February 03, 2004 10:00 PM Subject: Re: problem with applet to j2ee session handling Hi Kamal, Connecting an applet to a servlet via an http connection works fine if i use the java.net package using getCodeBase().openConnection(). I dont need to specify anywhere the session id (which i dont know how to get). But if i do the same via a GetMethod of httpclient, it doesnt work, my connection is redirected to the login page. I guess that I need to get the j2ee session id somewhere and give it (as a header ?) to the http method before execution... Does anyone have an idea about how it should go ? J2EE sessions are stored either as a parameter in the URL or as a cookie. In this case it sounds like it's in a cookie which on IE for Windows will automatically be sent back when using the standard URL classes. For HttpClient and most other systems you have to manually send the cookie yourself. You can retrieve it using javascript with document.cookie and then pass it in to the applet as a parameter which can then be passed through to HttpClient. I believe Matt Drance from Apple has polished up these instructions for me and posted them as a FAQ somewhere on Apple's site so it's probably worth doing a bit of a dig around there for more info. If you can't find it and need more help I can do up some example code for you. Kamal El Bedraoui Regards, Adrian Sutton. -- Intencha tomorrow's technology today Ph: 38478913 0422236329 Suite 8/29 Oatland Crescent Holland Park West 4121 Australia QLD www.intencha.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
How to diable Keep-Alive?
Hi, i want to avoid, that POST-Requests reuse connections from the pool. I'm using the MultiThreadedHttpConnectionManager because i use one HttpClient-Object from different Threads. By avoiding that POST-Request use already open HTTP-connections, i want to avoid problems with stale connections since i use InputStreams for POST-requests. Is this possibility? As far as i understood Ortwin in de.comp.lang.java, stale connections and POST-Requests and InputStreams lead to problems since a InputStream cannot be rewound. How does HttpClient currently try to work around that? - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
SSLHandshakeException: Remote host closed connection during handshake ????
Hi, I'm having a few problems connecting to a https server. I keep getting the following exception being thrown. javax.net.ssl.SSLHandshakeException: Remote host closed connection during handshake It uses its own issued certificate so I'm using the easySSLProtocolSocketFactory to get around the fact that the cert is not trusted, but the problem is still there. I'm using the simple sample code for connecting to a socket as supplied by the commons/httpclient website (with mods for above). The address is: https://mail.webavinet.net/ and I can connect using a web browser with no problem (appart form the cert issuer). It wouldn't be anything to do with the cert being 1024bit would it? Anyone any ideas??? Thanks Marc Concannon Failed to download file. javax.net.ssl.SSLHandshakeException: Remote host closed connection during handshake at com.sun.net.ssl.internal.ssl.SSLSocketImpl.a(Unknown Source) at com.sun.net.ssl.internal.ssl.SSLSocketImpl.j(Unknown Source) at com.sun.net.ssl.internal.ssl.SSLSocketImpl.a(Unknown Source) at com.sun.net.ssl.internal.ssl.AppOutputStream.write(Unknown Source) at org.apache.commons.httpclient.HttpConnection$WrappedOutputStream.write(HttpConnection.java:1368) at java.io.BufferedOutputStream.flushBuffer(Unknown Source) at java.io.BufferedOutputStream.flush(Unknown Source) at org.apache.commons.httpclient.HttpConnection.flushRequestOutputStream(HttpConnection.java:799) at org.apache.commons.httpclient.HttpMethodBase.writeRequest(HttpMethodBase.java:2277) at org.apache.commons.httpclient.HttpMethodBase.processRequest(HttpMethodBase.java:2657) at org.apache.commons.httpclient.HttpMethodBase.execute(HttpMethodBase.java:1093) at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:674) at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:529) at com.universalred.connectix.TcpConnectionManager.getHttpsConnection(TcpConnectionManager.java:184) at com.universalred.connectix.NewRequestManagement.newPositiveFileUpdate(NewRequestManagement.java:34) at com.universalred.connectix.FileDirectoryMonitor.run(FileDirectoryMonitor.java:76) Caused by: java.io.EOFException: SSL peer shut down incorrectly at com.sun.net.ssl.internal.ssl.InputRecord.read(Unknown Source) ... 16 more