Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Problem in session

Posted on 2011-03-14
2
Medium Priority
?
238 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 2000 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

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

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

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…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

877 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