java - addCookie() not working in Tomcat 7 -
currently in process migrate application tomcat 6 tomcat 7. in flow there part add together cookie servlet jsp in method of servlet. neither adding cookie nor throwing exception. cross check have tried add together cookie within jsp forcefully. got same result.
servlet.java
public void logon( string username, string password, string ip, httpservletresponse response) throws exception, logonfailure { system.out.println(" input received ::"+response); system.out.println("attachment :::"+getnextattachment()); authenticatorticketwrapper wrapper = new authenticatorticketwrapper( username, password, ip, "" + getnextattachment(), ); // if no exception thrown must of managed log on. string userid = "" + this.getnextid(); system.out.println("user id within logon method ::"+userid); wrapper.setusername(userid); //wrapper.set m_cache.put( userid, wrapper ); // add together cookie users browser seek { system.out.println("cookiename in logon method :"+cookiename); response.addcookie( new cookie(this.cookiename + this.creation_id, userid) ); response.addcookie( new cookie(this.cookiename + this.creation_key, wrapper.getusercookiekey() ) ); } grab (exception e) { // todo: handle exception system.out.println("failed add together cookie, exception " + se); } }
catalina.policy
// permission examples/samples - see context xml files grant codebase "file:${catalina.home}/webapps/creationweb/-" { permission java.security.allpermission; };
can please allow me know if missing anything?
i've used code such next set cookies in tomcat 7
cookie usercookie = new cookie("somename", "somevalue"); usercookie.setmaxage(99999999999); usercookie.setpath("/"); resp.addcookie(usercookie);
in above example, resp httpservletresponse. code tested , working tomcat 7 , in jdk 1.7
java jsp tomcat servlets cookies
No comments:
Post a Comment