Featured post
java - Maintaining Session using HTTPClient on a Rails Application -
i have applet talks rails application. wish maintain user's session applet's communication recognized part of user's browsing session. use apache's httpclient send request rails application not recognize request part of users session.
this code use build request, pass in session_id variable , http_cookie variable applet parameters:
httpclient client = new httpclient(); cookie httpcookie = new cookie("localhost", "http_cookie", http_cookie, "/", null, false); cookie sessionid = new cookie("localhost", "session_id", session_id, "/", null, false); httpstate initialstate = new httpstate(); initialstate.addcookie(httpcookie); initialstate.addcookie(sessionid); client.setstate(initialstate); postmethod post = new postmethod("http://localhost:3001/vizs/add");
any suggestions great!
slothishtype
i solved following code:
string session_id_str = "6a7eec105k231g51bjd0655e638034f3";
cookie sessionid = new cookie("127.0.0.1:3001", "_chatter_session", session_id_str, "/", null, false);
httpstate initialstate = new httpstate();
initialstate.addcookie(sessionid);
client.setstate(initialstate);
the 2 problems were:
1) not putting port number in url.
2) specifying wrong session id. in example application called chatter session_id _chatter_session. add session id applet parameter.
- Get link
- X
- Other Apps
Comments
Post a Comment