Solved

Problem in session

Posted on 2011-03-14
2
233 Views
Last Modified: 2012-05-11
HI ,

I have created a application . in the login screan i put that user name in session. my application is working fine before calling web services .

while i am calling web services i set some values in cokkies , for session id creation .
after successfull call of web services  all session value are null ?
i dont know why ??  
private static String getCookieFromHeaders(HttpURLConnection wsConnection) {                 
     String headerValue = "FAIL";                                                             
     int i = 0;                                                                               
     do {                                                                                     
         String headerName = wsConnection.getHeaderFieldKey(i);                               
         if (headerName != null && headerName.equals("Set-Cookie")) {                         
             headerValue = wsConnection.getHeaderField(i);                                    
             break;                                                                           
         }                                                                                    
         i++;                                                                                 
     } while (true);                                                                          
     return headerValue;                                                                      
 }                                                                                            
                                                                                              
 private static void setSessionIdFromCookie(String sessionString) {                           
     int jsessionIdx = 0;                                                                     
     jsessionIdx = sessionString.indexOf("jsessionid=");                                      
     if (jsessionIdx >= 0) {                                                                  
         sessionString = sessionString.substring(jsessionIdx);                                
         setSessionId(sessionString.substring(11, sessionString.indexOf(";")));               
     }                                                                                        
 }

Open in new window


this two method only call for session creation is this problem .


or iam seeting httpConnection property for cokkies as fasle?

which one is the problem ?l

0
Comment
2 Comments
 
LVL 47

Accepted Solution

by:
for_yan earned 500 total points
ID: 35129341
If you are creating the server-side application with Java - do you really need to take care of cookies explicitly?
I'd think that HttpSession object should take care of maintaining your session and store your session variables
for you and you should not be dealing with cookies yourself? (In fact HttpSession  does it through cookies, but you don't need
to worry about them explicitly).

0
 
LVL 20

Author Closing Comment

by:Sathish David Kumar N
ID: 35138734
Problem in my code !!
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
eclipse shortcuts 9 63
Unhandled exception type Exception 18 42
mysql jsp example issue 32 51
SequenceInputStream example 3 19
Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question