hi all ,
i wrote the codes so that it can login as well as logout , but the problem is the cookies are not being retrieved.
cookie setting class :
remove cookie class(uncookie.java)
now iam unable to retrieve the "regcookie" as mentioned in comments in first code , is there a problem in setting cookies for the session.
when checked for cookies i found that there are 2 cookies in browser "JSESSIONID" and "regcookie".but when iretrieve iget only "JSESSIONID"
not the one i had set and morever i get the length of cookie set as "1" but i should have got "2" .
i think may be the cookie setting and retrieving is not correct .
I could not find how you were calling regfound servlet. As we know that cookie is being set on this so this servlet must be called before books.jsp only. I tweaked the code a bit and added a doGet method in regfound servlet created web.xml entry for same.
After it, I called this servlet from browser first and then books.jsp. In this case I was returning the value of <%=cf%> = true.
Kindly call this servlet (after including doGet method) first and then jsp. This would definitely work at your end as well.
Joined: Feb 16, 2009
thanks Salil Vverma ,
but i cannot understand a couple of things & have got some errors . please clear me.
Salil Vverma wrote:servlet must be called before books.jsp only.
i have called it , as i have already mentioned in post above that i can see two cookies "JSESSIONID" and "regcookie" in browser it means cookie setting is correct(may be its not set according to requirement)
Salil Vverma wrote:I added a doGet method in regfound servlet
explain me why shall i need this i am already passng my data in "post" method.
Salil Vverma wrote:created web.xml entry for same.
well i shouldnot ask this , but how to set this
Salil Vverma wrote:private static final long serialVersionUID = 1L;
may be "JSESSIONID" should be used instead of "serialVersionUID" because i donot see "serialVersionUID" beaing used at any point of program.
one more thing : the code works in servlet but not in jsp .
jsp is converted to servlet before it is processed. Just try to identify what the difference would be in the code between the servlet which is working at your end and in the servlet when it would have been converted to servlet.
You might need to check whether the servlet which is setting the cookie is being called before you call this jsp.