Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Problem in session

Posted on 2011-03-14
2
Medium Priority
?
237 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
In this post we will learn different types of Android Layout and some basics of an Android App.
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
Suggested Courses

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