Getting the SessionID?

I'm trying to get the current session id from an applet and I keep on getting NULL as the session id. Here's the code that I've wrote:
// Define a URL
               url = new URL(queryParam);
               // Get a URLConnection Object
               connection = (HttpURLConnection)url.openConnection();
connection.setRequestProperty("Connection", "close");
connection.setDoOutput(true);
DataOutputStream out=new DataOutputStream(connection.getOutputStream());
//ut.writeBytes(param);
out.flush();
out.close();
System.out.println("send data");
System.out.println("getting cookie");
// Get current Session
cookieHeader = connection.getHeaderField("Set-Cookie");
if(cookieHeader!=null)
int index = cookieHeader.indexOf(";");
if(index >= 0)
cookie = cookieHeader.substring(0, index);
System.out.println("Cookie is : "+ cookie);
System.out.println("Cookie is : "+ cookieHeader);
else
System.out.println("COOKIE IS NULL");
}

If you don't have the current session ID, your applet is going to be given a new one by the server, so you really should write the session ID as an applet parameter in the page:
<applet ...>
<param name="sessionId" value="<%= session.getId() %>" />

Similar Messages

  • Get the sessionID in an EJB

    Hello,
    I would like to add the session ID as an extra info in my log (log=DB).
    There is no problem when I use a Servlet but in an EJB this information doesn't exists any more. Where can I put this session ID to avoid to pass it in parameter ? I prefer avoid to store it in the Principal.
    Thx in advance

    If you go the ThreadLocal route, try setting it with a filter:
    public class SessionAccess {
        private static final ThreadLocal SESSION_IDS = new ThreadLocal();
        public static String getId() {
            return (String)SESSION_IDS.get();
        public static void setId(String id) {
            SESSION_IDS.set(id);
    import java.io.IOException;
    import javax.servlet.Filter;
    import javax.servlet.FilterChain;
    import javax.servlet.FilterConfig;
    import javax.servlet.ServletException;
    import javax.servlet.ServletRequest;
    import javax.servlet.ServletResponse;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpSession;
    public class SessionAccessFilter implements Filter {
        private FilterConfig filterConfig;
        public SessionAccessFilter() {
            super();
        public void init(FilterConfig filterConfig) throws ServletException {
            this.filterConfig = filterConfig;
        public void destroy() {
            this.filterConfig = null;
        public void doFilter(ServletRequest request,
                             ServletResponse response,
                             FilterChain chain) throws IOException, ServletException {
            HttpSession session = ((HttpServletRequest)request).getSession(true);
            String sessionId = session.getId();
            try {
                SessionAccess.setId(sessionId);
                chain.doFilter(request, response);
            } finally {
                SessionAccess.setId(null);
    }Then, in your EJB, you should be able to access the session id with:
    String sessionId = SessionAccess.getId();

  • How to get UCCX sessionID in vxml

    Hi,
    Is there a way to get the sessionID of the UCCX call in VXML. I want to use it from Nuance VXML. It think it should be something like: sesssion.connection.sessionid , but I don't find the right format.
    Thank you,
    Daniel

    Hi Daniel,
    what generates the VXML?
    I can imagine it is a simple dynamic web application, that may accept a HTTP GET parameter. If so, the UCCX script can be configured (perhaps with the Voice Browser step) to issue a HTTP request with the GET parameter of sessonid with the value of the session id, the dynamic web application would include this string in the VXML.
    By the way, what is Nuance VXML? VXML is rendered by UCCX, Nuance is only a Speech server as far as I know.
    G.

  • How can i get the value stored in the session object using its sessionid

    how can i get the value stored in the session object using its sessionid by running stand alone java application

    myforum wrote:
    how can i get the value stored in the session object using its sessionid by running stand alone java applicationThis does not seem to make sense! You need at least to give a lot more detail of what you are doing.

  • Could I get a exist session by the sessionID???

    Hi all...
    I wanna buile a administrator tool in internet.The main utility of this tool is to monitor every session, could I get the session just by the sessionID in deferent process.
    Thanx alot..

    You can get a session by it's id. just check the Servlet API docu, there you find the methodes in the "session" section.
    If you want to get some more detailed help i would be helpful if you give us a little bit more information about what you have and what you are trying to do.

  • How to get the information like IP address,Host name of connected clients v

    Hi Every one,
    I want to get the information like (IP Address,Hostname,Active sessions , Database Server….etc) of the connected clients
    via V$Views(ORACLE).
    And then I like to load these infromation into a table “Client_Table”.
    Could some one give me suggestion that which V$ views/method I use in order to get the above information and then
    how to load these information into a table “Client_table”?
    Your suggestions will be highly appreciated.
    With Regards
    BILAL

    You could use a LOGON TRIGGER so every session insert its own environment into your client_info table.
    You could use the following view and choose whatever attribute you need:
    create or replace view my_userenv (
    AUDITED_CURSORID ,
    AUTHENTICATION_DATA ,
    AUTHENTICATION_TYPE ,
    BG_JOB_ID ,
    CLIENT_IDENTIFIER ,
    CLIENT_INFO ,
    CURRENT_SCHEMA ,
    CURRENT_SCHEMAID ,
    CURRENT_SQL ,
    CURRENT_USER ,
    CURRENT_USERID ,
    DB_DOMAIN ,
    DB_NAME ,
    ENTRYID ,
    EXTERNAL_NAME ,
    FG_JOB_ID ,
    GLOBAL_CONTEXT_MEMORY ,
    HOST ,
    INSTANCE ,
    IP_ADDRESS ,
    ISDBA ,
    LANG ,
    LANGUAGE ,
    NETWORK_PROTOCOL ,
    NLS_CALENDAR ,
    NLS_CURRENCY ,
    NLS_DATE_FORMAT ,
    NLS_DATE_LANGUAGE ,
    NLS_SORT ,
    NLS_TERRITORY ,
    OS_USER ,
    PROXY_USER ,
    PROXY_USERID ,
    SESSION_USER ,
    SESSION_USERID ,
    SESSIONID ,
    TERMINAL
    ) AS SELECT
    SYS_CONTEXT ('USERENV', 'AUDITED_CURSORID') ,
    SYS_CONTEXT ('USERENV', 'AUTHENTICATION_DATA') ,
    SYS_CONTEXT ('USERENV', 'AUTHENTICATION_TYPE') ,
    SYS_CONTEXT ('USERENV', 'BG_JOB_ID') ,
    SYS_CONTEXT ('USERENV', 'CLIENT_IDENTIFIER') ,
    SYS_CONTEXT ('USERENV', 'CLIENT_INFO') ,
    SYS_CONTEXT ('USERENV', 'CURRENT_SCHEMA') ,
    SYS_CONTEXT ('USERENV', 'CURRENT_SCHEMAID') ,
    SYS_CONTEXT ('USERENV', 'CURRENT_SQL') ,
    SYS_CONTEXT ('USERENV', 'CURRENT_USER') ,
    SYS_CONTEXT ('USERENV', 'CURRENT_USERID') ,
    SYS_CONTEXT ('USERENV', 'DB_DOMAIN') ,
    SYS_CONTEXT ('USERENV', 'DB_NAME') ,
    SYS_CONTEXT ('USERENV', 'ENTRYID') ,
    SYS_CONTEXT ('USERENV', 'EXTERNAL_NAME') ,
    SYS_CONTEXT ('USERENV', 'FG_JOB_ID') ,
    SYS_CONTEXT ('USERENV', 'GLOBAL_CONTEXT_MEMORY') ,
    SYS_CONTEXT ('USERENV', 'HOST') ,
    SYS_CONTEXT ('USERENV', 'INSTANCE') ,
    SYS_CONTEXT ('USERENV', 'IP_ADDRESS') ,
    SYS_CONTEXT ('USERENV', 'ISDBA') ,
    SYS_CONTEXT ('USERENV', 'LANG') ,
    SYS_CONTEXT ('USERENV', 'LANGUAGE') ,
    SYS_CONTEXT ('USERENV', 'NETWORK_PROTOCOL') ,
    SYS_CONTEXT ('USERENV', 'NLS_CALENDAR') ,
    SYS_CONTEXT ('USERENV', 'NLS_CURRENCY') ,
    SYS_CONTEXT ('USERENV', 'NLS_DATE_FORMAT') ,
    SYS_CONTEXT ('USERENV', 'NLS_DATE_LANGUAGE') ,
    SYS_CONTEXT ('USERENV', 'NLS_SORT') ,
    SYS_CONTEXT ('USERENV', 'NLS_TERRITORY') ,
    SYS_CONTEXT ('USERENV', 'OS_USER') ,
    SYS_CONTEXT ('USERENV', 'PROXY_USER') ,
    SYS_CONTEXT ('USERENV', 'PROXY_USERID') ,
    SYS_CONTEXT ('USERENV', 'SESSION_USER') ,
    SYS_CONTEXT ('USERENV', 'SESSION_USERID') ,
    SYS_CONTEXT ('USERENV', 'SESSIONID') ,
    SYS_CONTEXT ('USERENV', 'TERMINAL')
    from dual;

  • Get the last query from the current user

    Is there a way to get the last query of the current user, so every query could be log with a database trigger?
    Let's just say I execute:
    DELETE xxxx;
    I tried :
    SELECT T.SQL_TEXT FROM V$SQLAREA T where ADDRESS=(SELECT prev_sql_addr FROM v$session where audsid=userenv('sessionid'));
    But the result of this query is :
    'SELECT T.SQL_TEXT FROM V$SQLAREA T where ADDRESS=(SELECT prev_sql_addr FROM v$session where audsid=userenv('sessionid'))'
    Is there a way to execute a query that would return :
    'DELETE xxxx'
    Thanks

    You could join SQL_ADDR in v$session with ADDRESS in v$sqlarea to determine the SID that executed that SQL statement last. Note that PREV_SQL_ADDR in v$session will indicate the previous SQL he executed. Though you would have to look at these tables very often to get all SQL statements issued. One note here, I think if a different user ran the SAME SQL with just bind var differences the SQL_AREA will only show the last user’s information that executed it.
    BTW - it will show deletes also...

  • JAAS LoginModule - how do I get the "JSessionId"

    Hi,
    is there any possibility to get the JSessionId from a custom JAAS LoginModule for the WebAS 6.40 Server.
    My first attempt was to read the JSESSIONID-Cookie from the Http-Request via the HttpGetterCallback-Class.
    ((HttpGetterCallback) callbacks[1]).setType(HttpCallback.COOKIE);
    ((HttpGetterCallback) callbacks[1]).setName("JSESSIONID");
    It worked well, till I noticed that sometimes the JSessionId-Cookie doesn't exist.
    The reason is, that the JSession-Cookie was set after the http-request has passed my login-modul.
    So, if I got a cookie-value, it sometimes was the JSessionID from an earlier session.
    So, my question:
    Is there any other posibility to get the JSessionId?
    If there is a way to get the ServletRequest-instance,  I could reach the SessionId via "HttpServletRequest.getSession()".
    Any idea? Any hints?
    Regards
    Steffen Spahr

    This is only available for NetWeaver Portal, not NetWeaver Application Server(WebAS). host and port can be obtained using the following code:
                   Callback[] callbacks = new Callback[3];
                   callbacks[0] = new NameCallback("UserId: ");
                   callbacks[1] = new PasswordCallback("Password: ", false);
                   // get host name and port
                   HttpGetterCallback getterCallback = new HttpGetterCallback();
                   getterCallback.setType(HttpCallback.HEADER);
                   getterCallback.setName("Host");
                   callbacks[2] = getterCallback;
                   try {
                        callbackHandler.handle(callbacks);
                   } catch (Exception ex) {
                        throw new LoginException(ex + "");
                   Object retValue = ((HttpGetterCallback)callbacks[2]).getValue(); //get host
    host and port will be returned in the following format SERVER.COMPANY.COM:50000
    Currently WebAS is not able to return the resource as per SAP development.

  • How do I get the session_id for form

    On open a form , portal is generating a session_id for that form ; who do I get it ?
    I can query wwa_module_sessions$ , but say if two or more different end users open the same form , I'll have two or more session_ids for the same module. How do I get the right one (session_id) ?
    Thanks
    Lawrence

    In com.iplanet.portalserver.session.Session class use the method given below,
    public SessionID getID()--->Returns the session ID
    If u need to get clientID then use the method given below,
    public java.lang.String getClientID()- Returns the client ID in this session

  • How can i have any way to get the session entity?

    HttpSessionContext.getSession(java.lang.String sessionId) is Deprecated,how can i get
    the session with sessionID?

    I have even hard situation that I need the getSession(String sessionId) method badly. I don't want just simply invalidate the session when user logoff. the problem occurs when user press X to terminate the browser abnormally or user's machine has power failure, or machine rebooting in the middle of running application. If any thing happens, I need to release the resource such as DB connection, record lock and so on so forth. In other word, I need to monitor if user no longer using the session. Is there any way I can do the clean up job? The question will still be is there any way I can get HttpSession object by using sessionId? It will not work If I save it on server side HashMap. Any suggestion? Thanks in advance.
    John

  • Getting same sessionId

    Hi,
    I have two application running in a single browser(Say two login pages in Internet explorer separated in frames).
    Now i sent a request to login from both the frames.
    After getting the response from the container i m printing the session id of HttpSession.What I get is same session id in both the frame.
    However if i printed the session object itself i got two different objects.
    Now i am unable to understand how two different request printed the same session Id but the different session object.
    And if the session id for two application is same then can i set an attribute to the session from one application and retrieve it from the other window.
    Is it the case that Internet explorer carries the same session across different window?
    Amin

    I presume the following reason may be responsible for this behaviour.
    The session handling in Servlets is based upon the sessionID encoded by using encodeURL method of HttpResponse object. This encoding may be happen in either URL encoding/ Cookie encoding transparently.
    The cookie(and hence sessionID) handled by an instance of browser is common to both frames hence when a request reaches servletEngine, it tries to recreate the HttpSession by using the sessionID passed in the background(by the part of HttpRequest), Now since both frames are passing same sessionIDs different HttpSession will have same SessionID.
    Hope this clears some of the doubts, If you get some better reasoning,
    Please let me know.
    regards
    Ravi

  • I am having macbook air recently my iphotos did not open and was showing report apple and reopen but i came to know that by pressing alt and iphotos i open an new photo library and stored the pics but now how can i get the pics which i had in the earlier

    i am having macbook air recently my iphotos did not open and was showing report apple and reopen but i came to know that by pressing alt and iphotos i open an new photo library and stored the pics but now how can i get the pics which i had in the earlier photo please help me to recover my photos

    Well I'll guess you're using iPhoto 11:
    Option 1
    Back Up and try rebuild the library: hold down the command and option (or alt) keys while launching iPhoto. Use the resulting dialogue to rebuild. Choose to Repair Database. If that doesn't help, then try again, this time using Rebuild Database.
    If that fails:
    Option 2
    Download iPhoto Library Manager and use its rebuild function. (In early versions of Library Manager it's the File -> Rebuild command. In later versions it's under the Library menu.)
    This will create an entirely new library. It will then copy (or try to) your photos and all the associated metadata and versions to this new Library, and arrange it as close as it can to what you had in the damaged Library. It does this based on information it finds in the iPhoto sharing mechanism - but that means that things not shared won't be there, so no slideshows, books or calendars, for instance - but it should get all your events, albums and keywords, faces and places back.
    Because this process creates an entirely new library and leaves your old one untouched, it is non-destructive, and if you're not happy with the results you can simply return to your old one.  
    Regards
    TD

  • Unable to get the values from ISearchResultList

    Hi,
    I am working on KM Indexmanagemnt API for searching with TREX, to build a search similar to msn or google.
    I am following the example of Thilo Brandt, and after building the query, I am unable to retrieve the result from ISearchResultList, the results size its displaying is zero. But session.getTotalNumberResultKeys() is retrieving a value 20.
    Here is the code I am using, please tell me where I am doing wrong.
    public class SearchComponetOne extends AbstractPortalComponent {
         public void doContent(IPortalComponentRequest request,     IPortalComponentResponse response) {
      com.sap.security.api.IUser nwUser =
                   UMFactory.getAuthenticator().getLoggedInUser();
    com.sapportals.portal.security.usermanagement.IUser user = null;
    try {
          user = WPUMFactory.getUserFactory().getEP5User(nwUser);
         } catch (UserManagementException e) {
                   response.write(e.getMessage());
       response.write("<html><head><title>Search</title></head><body>");
      ResourceContext c = new ResourceContext(user);
      try {
        IIndexService indexService = (IIndexService) ResourceFactory
                             .getInstance()
                             .getServiceFactory()
                             .getService(
                             IServiceTypesConst.INDEX_SERVICE);
       SearchQueryListBuilder sqb = new SearchQueryListBuilder();
       sqb.setSearchTerm("sap");
      IQueryEntryList qel = sqb.buildSearchQueryList();
      // get an instance of federated search
    IFederatedSearch federatedSearch =
                   (IFederatedSearch) indexService.getObjectInstance(
              IWcmIndexConst.FEDERATED_SEARCH_INSTANCE);
         List indexList = new ArrayList();
         String index = null;
         if (index != null && index.length() > 0) {
              // take a specified index from index= parameter
              indexList.add(indexService.getIndex(index));
         } else {
              // take all available indexes
              indexList = indexService.getActiveIndexes();
         // it is recommended to use a search session object
         // for searching execution
         ISearchSession session = null;
         if (session == null)
         session = federatedSearch.searchWithSession(qel, indexList, c);
    response.write("Inside doContent session.getNumberResultKeys() => " + session.getNumberResultKeys()); // output as 20
         this.renderResultHeader(response, session, indexList);
         // get all results from the search session
    ISearchResultList results =     session.getSearchResults(1, session.getTotalNumberResultKeys());
    response.write(" from session => " + results.size() + " and size is : " + results.toString());  // I am getting the results.size() as zero
    Thanks

    I think the problem is UME related. I had the same problem once. Try using a system user for searching, instead of the logged on user.
    Like this:
    com.sapportals.portal.security.usermanagement.IUser user = WPUMFactory.getUserFactory().getUser("cmadmin_service");
    Please reward the points if this helps.

  • How to get the values from popup window to mainwindow

    HI all,
       I want to get the details from popup window.
          i have three input fields and one search button in my main window. when i click search button it should display popup window.whenever i click on selected row of the popup window table ,values should be visible in my main window input fields.(normal tables)
       now i am able to display popup window with values.How to get the values from popup window now.
       I can anybody explain me clearly.
    Thanks&Regards
    kranthi

    Hi Kranthi,
    Every webdynpro component has a global controller called the component controller which is visible to all other controllers within the component.So whenever you want to share some data in between 2 different views you can just make it a point to use the component controller's context for the same. For your requirement (within your popups view context) you will have have to copy the component controllers context to your view. You then will have to (programmatically) fill this context with your desired data in this popup view. You can then be able to read this context from whichever view you want. I hope that this would have made it clear for you. Am also giving you an [example|http://****************/Tutorials/WebDynproABAP/Modalbox/page1.htm] which you can go through which would give you a perfect understanding of all this. In this example the user has an input field in the main view. The user enters a customer number & presses on a pushbutton. The corresponding sales orders are then displayed in a popup window for the user. The user can then select any sales order & press on a button in the popup. These values would then get copied to the table in the main view.
    Regards,
    Uday

  • How to get the values from a html form embedded in a swing container

    Hi all,
    I am developing an application in which i have to read a html file and display it in a swing container.That task i made it with the help of a tool.But now i want to get the values from that page.ie when the submit button is clicked all the values of that form should be retrived by a servlet/standalone application.I don't know how to proceed further.Any help in this regard will be very greatful
    Thanks in advance,
    Prakash

    By parsing the HTML.

Maybe you are looking for