Solved

Problem in session

Posted on 2011-03-14
2
230 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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

For customizing the look of your lightweight component and making it look lucid like it was made of glass. Or: how to make your component more Apple-ish ;) This tip assumes your component to be of rectangular shape and completely opaque. (COD…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
This video teaches viewers about errors in exception handling.

705 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now