Re: [Dev] Session maintain in HttpClient
Hi Godwin, As a side note if you use http-client you can send maximum two concurrent requests which is not sufficient for production setups. You can use connection managers such as PoolingConnectionManagers which provides more fine grained configurations. [1] http://hc.apache.org/httpcomponents-client-ga/httpclient/apidocs/org/apache/http/impl/conn/PoolingClientConnectionManager.html Touched, not typed. Erroneous words are a feature, not a typo. On Oct 23, 2014 9:39 PM, ud...@wso2.com wrote: Hi Laxman, Yes session variables are stored in server side. But server should identify subsequent request are from the same client right. Since HTTP is stateless cookies(ex JSessionId) is used to identify the client. That's what HTTP context might do. Otherwise normal multiple HTTP calls won't be recognized as separate clients. @Godwin hope it is your requirement. Touched, not typed. Erroneous words are a feature, not a typo. ___ Dev mailing list Dev@wso2.org http://wso2.org/cgi-bin/mailman/listinfo/dev
Re: [Dev] Session maintain in HttpClient
Hi Laxman, Yes session variables are stored in server side. But server should identify subsequent request are from the same client right. Since HTTP is stateless cookies(ex JSessionId) is used to identify the client. That's what HTTP context might do. Otherwise normal multiple HTTP calls won't be recognized as separate clients. @Godwin hope it is your requirement. Touched, not typed. Erroneous words are a feature, not a typo. ___ Dev mailing list Dev@wso2.org http://wso2.org/cgi-bin/mailman/listinfo/dev
[Dev] Session maintain in HttpClient
Hi, I am using org.apache.http.client.HttpClient to send http request, here I want to maintain the session. Ex. I have a web application hosted in tomcat. web app has a *test1.jsp* which set session attribute *code. *there is a another JSP called *test2.jsp* which get the session attribute *code *and print it*. *I use HttpClient and send a request to *test1.jsp *and then *test2.jsp, *when I call the *test2.jsp *it cannot get the session attribute *code *and session is not maintained. Can anyone suggest a solution for this. Thanks Godwin -- *Godwin Amila Shrimal* Senior Software Engineer WSO2 Inc.; http://wso2.com lean.enterprise.middleware mobile: *+94772264165* linkedin: *http://lnkd.in/KUum6D http://lnkd.in/KUum6D* twitter: https://twitter.com/godwinamila ___ Dev mailing list Dev@wso2.org http://wso2.org/cgi-bin/mailman/listinfo/dev
Re: [Dev] Session maintain in HttpClient
Hi Amila, Use same httpContext object to create httpclient connections to test1 and test2 jsps. Thanks On Wed, Oct 22, 2014 at 5:45 PM, Godwin Amila Shrimal god...@wso2.com wrote: Hi, I am using org.apache.http.client.HttpClient to send http request, here I want to maintain the session. Ex. I have a web application hosted in tomcat. web app has a *test1.jsp* which set session attribute *code. *there is a another JSP called *test2.jsp* which get the session attribute *code *and print it*. *I use HttpClient and send a request to *test1.jsp *and then *test2.jsp, *when I call the *test2.jsp *it cannot get the session attribute *code *and session is not maintained. Can anyone suggest a solution for this. Thanks Godwin -- *Godwin Amila Shrimal* Senior Software Engineer WSO2 Inc.; http://wso2.com lean.enterprise.middleware mobile: *+94772264165* linkedin: *http://lnkd.in/KUum6D http://lnkd.in/KUum6D* twitter: https://twitter.com/godwinamila ___ Dev mailing list Dev@wso2.org http://wso2.org/cgi-bin/mailman/listinfo/dev -- Manoj Gunawardena Tech Lead WSO2, Inc.: http://wso2.com lean.enterprise.middleware Mobile : +94 77 2291643 ___ Dev mailing list Dev@wso2.org http://wso2.org/cgi-bin/mailman/listinfo/dev
Re: [Dev] Session maintain in HttpClient
Hi Amila, As I understood session should maintain in server not client right? and is these two Jsp pages reside in same web application? if they are in same web app, one thing to notice is your session may be time out. make sure it is not. you can try adding below code in your jsp2 %@ page language=java contentType=text/html session=true % the solution in thread [1] may be helpful for setting session variable. http://www.experts-exchange.com/Programming/Misc/Q_21903762.html Thanks On Wed, Oct 22, 2014 at 7:29 PM, Manoj Gunawardena man...@wso2.com wrote: Hi Amila, Use same httpContext object to create httpclient connections to test1 and test2 jsps. Thanks On Wed, Oct 22, 2014 at 5:45 PM, Godwin Amila Shrimal god...@wso2.com wrote: Hi, I am using org.apache.http.client.HttpClient to send http request, here I want to maintain the session. Ex. I have a web application hosted in tomcat. web app has a *test1.jsp* which set session attribute *code. *there is a another JSP called *test2.jsp* which get the session attribute *code *and print it*. *I use HttpClient and send a request to *test1.jsp *and then *test2.jsp, *when I call the *test2.jsp *it cannot get the session attribute *code *and session is not maintained. Can anyone suggest a solution for this. Thanks Godwin -- *Godwin Amila Shrimal* Senior Software Engineer WSO2 Inc.; http://wso2.com lean.enterprise.middleware mobile: *+94772264165* linkedin: *http://lnkd.in/KUum6D http://lnkd.in/KUum6D* twitter: https://twitter.com/godwinamila ___ Dev mailing list Dev@wso2.org http://wso2.org/cgi-bin/mailman/listinfo/dev -- Manoj Gunawardena Tech Lead WSO2, Inc.: http://wso2.com lean.enterprise.middleware Mobile : +94 77 2291643 ___ Dev mailing list Dev@wso2.org http://wso2.org/cgi-bin/mailman/listinfo/dev -- Lakshman Udayakantha WSO2 Inc. www.wso2.com lean.enterprise.middleware Mobile: *0711241005* ___ Dev mailing list Dev@wso2.org http://wso2.org/cgi-bin/mailman/listinfo/dev
Re: [Dev] Session maintain in HttpClient
Hi, AFAIK, client session management should be handled by both client side and server side. If you use Servlet container like tomat, it automatically manage session and send the relevant session cookie to client side. If you want to use that session, in subsequent requests you have to send the same session cookie from client side. There may have easy mechanism to pass back and forth the session cookie in org.apache.http.client.HttpClient. Or otherwise you have to get the session cookie from previous http response and set it to the next http request manually. Thanks, Roshan Deniyage Associate Technical Lead WSO2, Inc: http://wso2.com Mobile: +94 777636406 Twitter: *https://twitter.com/roshku https://twitter.com/roshku* LinkedIn : https://www.linkedin.com/in/roshandeniyage On Wed, Oct 22, 2014 at 10:35 PM, Lakshman Udayakantha lakshm...@wso2.com wrote: Hi Amila, As I understood session should maintain in server not client right? and is these two Jsp pages reside in same web application? if they are in same web app, one thing to notice is your session may be time out. make sure it is not. you can try adding below code in your jsp2 %@ page language=java contentType=text/html session=true % the solution in thread [1] may be helpful for setting session variable. http://www.experts-exchange.com/Programming/Misc/Q_21903762.html Thanks On Wed, Oct 22, 2014 at 7:29 PM, Manoj Gunawardena man...@wso2.com wrote: Hi Amila, Use same httpContext object to create httpclient connections to test1 and test2 jsps. Thanks On Wed, Oct 22, 2014 at 5:45 PM, Godwin Amila Shrimal god...@wso2.com wrote: Hi, I am using org.apache.http.client.HttpClient to send http request, here I want to maintain the session. Ex. I have a web application hosted in tomcat. web app has a *test1.jsp* which set session attribute *code. *there is a another JSP called *test2.jsp* which get the session attribute *code *and print it*. *I use HttpClient and send a request to *test1.jsp *and then *test2.jsp, *when I call the *test2.jsp *it cannot get the session attribute *code *and session is not maintained. Can anyone suggest a solution for this. Thanks Godwin -- *Godwin Amila Shrimal* Senior Software Engineer WSO2 Inc.; http://wso2.com lean.enterprise.middleware mobile: *+94772264165* linkedin: *http://lnkd.in/KUum6D http://lnkd.in/KUum6D* twitter: https://twitter.com/godwinamila ___ Dev mailing list Dev@wso2.org http://wso2.org/cgi-bin/mailman/listinfo/dev -- Manoj Gunawardena Tech Lead WSO2, Inc.: http://wso2.com lean.enterprise.middleware Mobile : +94 77 2291643 ___ Dev mailing list Dev@wso2.org http://wso2.org/cgi-bin/mailman/listinfo/dev -- Lakshman Udayakantha WSO2 Inc. www.wso2.com lean.enterprise.middleware Mobile: *0711241005* ___ Dev mailing list Dev@wso2.org http://wso2.org/cgi-bin/mailman/listinfo/dev ___ Dev mailing list Dev@wso2.org http://wso2.org/cgi-bin/mailman/listinfo/dev
Re: [Dev] Session maintain in HttpClient
Hi Lakshman, Session in the server is maintaining properly, But server should recognize same client session accessing the resources, When we send an request to the server, server create an session, when we send an another request sever create another session. We need to send a cookie and access the same session. On Wed, Oct 22, 2014 at 10:35 PM, Lakshman Udayakantha lakshm...@wso2.com wrote: Hi Amila, As I understood session should maintain in server not client right? and is these two Jsp pages reside in same web application? if they are in same web app, one thing to notice is your session may be time out. make sure it is not. you can try adding below code in your jsp2 %@ page language=java contentType=text/html session=true % the solution in thread [1] may be helpful for setting session variable. http://www.experts-exchange.com/Programming/Misc/Q_21903762.html Thanks On Wed, Oct 22, 2014 at 7:29 PM, Manoj Gunawardena man...@wso2.com wrote: Hi Amila, Use same httpContext object to create httpclient connections to test1 and test2 jsps. Thanks On Wed, Oct 22, 2014 at 5:45 PM, Godwin Amila Shrimal god...@wso2.com wrote: Hi, I am using org.apache.http.client.HttpClient to send http request, here I want to maintain the session. Ex. I have a web application hosted in tomcat. web app has a *test1.jsp* which set session attribute *code. *there is a another JSP called *test2.jsp* which get the session attribute *code *and print it*. *I use HttpClient and send a request to *test1.jsp *and then *test2.jsp, *when I call the *test2.jsp *it cannot get the session attribute *code *and session is not maintained. Can anyone suggest a solution for this. Thanks Godwin -- *Godwin Amila Shrimal* Senior Software Engineer WSO2 Inc.; http://wso2.com lean.enterprise.middleware mobile: *+94772264165* linkedin: *http://lnkd.in/KUum6D http://lnkd.in/KUum6D* twitter: https://twitter.com/godwinamila ___ Dev mailing list Dev@wso2.org http://wso2.org/cgi-bin/mailman/listinfo/dev -- Manoj Gunawardena Tech Lead WSO2, Inc.: http://wso2.com lean.enterprise.middleware Mobile : +94 77 2291643 ___ Dev mailing list Dev@wso2.org http://wso2.org/cgi-bin/mailman/listinfo/dev -- Lakshman Udayakantha WSO2 Inc. www.wso2.com lean.enterprise.middleware Mobile: *0711241005* -- *Godwin Amila Shrimal* Senior Software Engineer WSO2 Inc.; http://wso2.com lean.enterprise.middleware mobile: *+94772264165* linkedin: *http://lnkd.in/KUum6D http://lnkd.in/KUum6D* twitter: https://twitter.com/godwinamila ___ Dev mailing list Dev@wso2.org http://wso2.org/cgi-bin/mailman/listinfo/dev
Re: [Dev] Session maintain in HttpClient
Hi Roshan, Correct. Server session is managed by Servlet container and Client session handled by Cookie, We need to get the cookie from first response and pass it to server via second request. BTW I tried it and not working properly. On Thu, Oct 23, 2014 at 10:05 AM, Roshan Deniyage rosh...@wso2.com wrote: Hi, AFAIK, client session management should be handled by both client side and server side. If you use Servlet container like tomat, it automatically manage session and send the relevant session cookie to client side. If you want to use that session, in subsequent requests you have to send the same session cookie from client side. There may have easy mechanism to pass back and forth the session cookie in org.apache.http.client.HttpClient. Or otherwise you have to get the session cookie from previous http response and set it to the next http request manually. Thanks, Roshan Deniyage Associate Technical Lead WSO2, Inc: http://wso2.com Mobile: +94 777636406 Twitter: *https://twitter.com/roshku https://twitter.com/roshku* LinkedIn : https://www.linkedin.com/in/roshandeniyage On Wed, Oct 22, 2014 at 10:35 PM, Lakshman Udayakantha lakshm...@wso2.com wrote: Hi Amila, As I understood session should maintain in server not client right? and is these two Jsp pages reside in same web application? if they are in same web app, one thing to notice is your session may be time out. make sure it is not. you can try adding below code in your jsp2 %@ page language=java contentType=text/html session=true % the solution in thread [1] may be helpful for setting session variable. http://www.experts-exchange.com/Programming/Misc/Q_21903762.html Thanks On Wed, Oct 22, 2014 at 7:29 PM, Manoj Gunawardena man...@wso2.com wrote: Hi Amila, Use same httpContext object to create httpclient connections to test1 and test2 jsps. Thanks On Wed, Oct 22, 2014 at 5:45 PM, Godwin Amila Shrimal god...@wso2.com wrote: Hi, I am using org.apache.http.client.HttpClient to send http request, here I want to maintain the session. Ex. I have a web application hosted in tomcat. web app has a *test1.jsp* which set session attribute *code. *there is a another JSP called *test2.jsp* which get the session attribute *code *and print it*. *I use HttpClient and send a request to *test1.jsp *and then *test2.jsp, *when I call the *test2.jsp *it cannot get the session attribute *code *and session is not maintained. Can anyone suggest a solution for this. Thanks Godwin -- *Godwin Amila Shrimal* Senior Software Engineer WSO2 Inc.; http://wso2.com lean.enterprise.middleware mobile: *+94772264165* linkedin: *http://lnkd.in/KUum6D http://lnkd.in/KUum6D* twitter: https://twitter.com/godwinamila ___ Dev mailing list Dev@wso2.org http://wso2.org/cgi-bin/mailman/listinfo/dev -- Manoj Gunawardena Tech Lead WSO2, Inc.: http://wso2.com lean.enterprise.middleware Mobile : +94 77 2291643 ___ Dev mailing list Dev@wso2.org http://wso2.org/cgi-bin/mailman/listinfo/dev -- Lakshman Udayakantha WSO2 Inc. www.wso2.com lean.enterprise.middleware Mobile: *0711241005* ___ Dev mailing list Dev@wso2.org http://wso2.org/cgi-bin/mailman/listinfo/dev ___ Dev mailing list Dev@wso2.org http://wso2.org/cgi-bin/mailman/listinfo/dev -- *Godwin Amila Shrimal* Senior Software Engineer WSO2 Inc.; http://wso2.com lean.enterprise.middleware mobile: *+94772264165* linkedin: *http://lnkd.in/KUum6D http://lnkd.in/KUum6D* twitter: https://twitter.com/godwinamila ___ Dev mailing list Dev@wso2.org http://wso2.org/cgi-bin/mailman/listinfo/dev