Having trouble with session.setAttribute()

Hi,
I'm trying to attach the current time to the sessionID as follows but it is not working.
long stime = System.currentTimeMillis() / 1000;
session.setAttribute("stime", stime);
Then I want to call it later on....
long stime = session.getAttribute("stime");
None of this is working. Can someone help me please...
thanks,
kramer

Hello,
Capital "L" Long is the Object representation or "wrapper" of a long (lowercase "l"), which is one of the basic types called primitives and is a reserved keyword in the Java Language.
As for uses, if you are simply dealing with long values in terms of basic arithmetic functions (+, -, *, /, etc.) then the primitive type will work fine. If you need to do fancier things, like conversion to another type, String representations, storage in a HashMap as an Object, etc. then that is for what the wrapper class is intended.
Good luck,
Ken

Similar Messages

  • Having trouble with session

    new to Jsp, previously Asp programmer. I'm not getting a session value returned. The first page the user puts in password and username, and the form is submitted to a jsp page. This page checks the database for validation. This works fine, it redirects to a main page when valid. I want to then just get the userid and display it (just to see if the session is working) on the previous page when I enter a non-valid password. I don't get any errors just userid = (nothing) ?? Any suggestions? Thanks for the help!!
    page 1 snippet --
    <%
    // first time make it true, then make it false to continue using the same session.
    session = request.getSession(false );
    // later, you'll want to go get userID this way.
    Sting User = (String)session.getAttribute("USER");
    %>
    User = <%=User%>
    page 2 snippet --
    String Password= request.getParameter("Password");
    String sql = "Select userID FROM Web_User WHERE PASSWORD = '" + Password +"'";
    (works fine)
    ...further down --
    HttpSession session = null;
    // first time make it true, then make it false to continue using the same session.
    session = request.getSession(true);
    // whatever fuction to go get the userID
    String userID = userID ";
    // set user id to session
    session.setAttribute("USER",userID);

    3) try to capture password as a session -
    String Plwork= "Password";
    session.setAttribute("USER",Plwork);
    This will place an attribute in the session
    The attribute name = "USER", value = "Password"
    Is this what you want?4) show password on another page after redirect -
    <% session = request.getSession(false);
    String PWord= (String)session.getAttribute("Plwork");
    %>
    PWord= <%= PWord%>
    You should not have to do a request.getSession(false);
    The session should already be there.
    With the code that you have provided there is NOT an
    attribute called "Plwork". So, you should get back
    a null Object.
    Hope that helps!

  • Having trouble with Element setAttribute()

    Hi. I am executing this simple statement:
    import org.w3c.dom.Element;
    Element xmlElem
    // Set xmlElem to first node of document here...
    xmlElem.setAttribute("counter",Integer.toString(counterInt));
    On the setAttribute() statement, I receive the following exception:
    org.apache.xml.dtm.DTMDOMException: at org.apache.xml.dtm.ref.DTMNodeProxy.setAttribute(DTMNodeProxy.java:1109)
    I ruled out the attribute being null by doing a xmlElem.getAttribute("counter") and checking the result. The method does not return null, and the attribute exists in the XML file.
    When I looked up the open source code for DTMNodeProxy, the setAttribute method of that class raises a DTMDOMException (just as I am getting), and does nothing else. This makes me think:
    1.) That I am missing an implementation jar somewhere, as it appears that Element's setAttribute method is not implemented (???)
    2.) There is a permissions issue with the XML file (but I did a chmod 777 on the file to rule this out).
    Any insight would be greatly appreciated. Thank you.

    You didn't happen to cut off the first line of the stack trace, where the exception message appears, did you?

  • Having trouble with persist

    I have created a simple application where a user can order items and then i'm saving the order and all the items (details of order) to the dataBase.
    i'm using jdk1.5 with jboss and mySql (also hibernate).
    i'm having troubles with saving the details of the order, the relevant code is-
    order entity -
    @Entity
    public class Orders implements Serializable
        @Id @GeneratedValue
        private long orderId;                    //generated in db
        private String name;
       public Orders(String userName)
            this.userName=userName;
        public long getOrderId() { return orderId; }
        //getters and setters...
    detailsOfOrder entity -
    @Entity
    public class DetailsOfOrders implements Serializable
    @Id
    private long orderId;
    @Id
    private int productId;
    private int quantity;
    public DetailsOfOrders(long orderId,int productId)
         this.productId=productId;
         this.orderId=orderId;
    public long getOrderId() { return orderId; }
    public int getProductId() { return productId; }
    //getters and setters...
    }session bean (order method) -
            List<SCItem> listOfItems;                         //SCItem is a regular class
            Orders order=new Orders(userName);
            manager.persist(order);
            long orderId=order.getOrderId();   //get order id after persisting
            for(SCItem item : listOfItems)    //save details of order
             DetailsOfOrders detail=new DetailsOfOrders(orderId,"1");
             manager.persist(detail);                                                   //exception occures here
           }when i'm trying to make an order i'm getting the exception-
    javax.transaction.RollbackException: [com.arjuna.ats.internal.jta.transaction.arjunacore.commitwhenaborted] [com.arjuna.ats.internal.jta.transaction.arjunacore.commitwhenaborted] Can't commit because the transaction is in aborted state
    what is the problem?
    thanks in advanced.

    yes, the entity classes have no-arg constructors (i just tried to write it shortly here...)
    about the other thing , well i'm sorry , the right code is-
    session bean (order method) -
       List<SCItem> listOfItems;                         //SCItem is a regular class
       Orders order=new Orders(userName);
       manager.persist(order);
       long orderId=order.getOrderId();   //get order id after persisting
       for(SCItem item : listOfItems)    //save details of order
         DetailsOfOrders detail=new DetailsOfOrders(orderId,item.getProductId());
         manager.persist(detail);                                                   //exception occures here
         }what else could it be?

  • Trouble with session variables

    Hello, I am a user of cf for a number of years, but only
    lately as of last week have I had the opportunity to work with CF
    8.... wow the changes are quite intimidating. But none the less
    press on is my thought, so now my trouble. Thing I did was to start
    using application.cfc vs application.cfm, as it would appear that
    is how things have come to pass. So I looked around and found this
    code to set session management:
    <cfcomponent output="false" hint="Handles application
    level events.">
    <!--- Set up the application. --->
    <cfset THIS.Name = "AppCFC" />
    <cfset THIS.ApplicationTimeout = CreateTimeSpan( 0, 0, 60,
    0 ) />
    <cfset THIS.SessionManagement = true />
    <cfset THIS.SetClientCookies = false />
    <CFSET request.dsn = "wlaw" />
    </cfcomponent>
    My problem is that while I can define a session variable on a
    page that is not under the SSL cert, my session vars become
    undefined once I land on a page under SSL.
    Am I missing something? I dont recall this being a problem in
    the past. All help is appreciated.
    as to setting the var, it is done on an index page which
    calls another page in a different directory, but under the same
    server,.
    <cfset session.ref="foo">
    the only changes are that the result page or action page if
    you prefer is now under the ssl and the var becomes undefined.
    thank you in advance
    Mike Dooly

    is the object being put in session context serializable.. Also in
              other to avoid any generated classes issues delete all the classes
              whcih weblogic generates as part of deploying the application. That
              should atleast mitigate one explanation for your problem.
              Hope this helps
              ~a
              [email protected] (Gabriel Ornelas De Luna) wrote in message news:<[email protected]>...
              > Hello everyone,
              > I'm currently working with WL 6.1 and I'm having trouble with the
              > persistence of some session variables which are initially created
              > correctly on the server side, and they get lost (null) once the Web
              > clients need to access its value.
              > This is the error which is being written on a log file:
              >
              > <May 13, 2003 3:05:09 PM EDT> <Error> <HTTP Session> <Could not
              > deserialize session data
              > java.io.NotSerializableException:
              >
              > Things were woriking perfectly, but suddenly after bouncing the server
              > instance several times, in order to pick up the latest changes in my
              > classes, I started to get this error once the server tries to load the
              > jsp.
              >
              > JSP Code:
              > <%
              > Integer businessID = (Integer) session.getAttribute("business_id" );
              > Util.isCapitolBusiness(businessID.intValue())
              > %>
              >
              > I appreciate your help.
              > Regards.
              > g.
              

  • Hi, i am having trouble with my mac mail account, i cannot send or receive any emails because of the server connection problems. Message says it could not be connected to SMTP server. Thanks in advance for your help.

    Hi, i am having trouble with my mac mail account, i cannot send or receive any emails because of the server connection problems. Message says it could not be connected to SMTP server. Thanks in advance for your help.

    Hello Sue,
    I have an iPad 3, iPad Mini and iPhone 5S and they are all sluggish on capitalisation using shift keys. I hope that Apple will solve the problem because it is driving me crazy.
    I find using a Microsoft Surface and Windows 8 phone, which I also have, work as well as all the ios devices before the ios 7 upgrade.
    It has something to do with the length of time that you need to hold the shift key down. The shift key needs to be held longer than the letter key for the capitalisation to work. For some reason, this is a major change in the way we have learnt to touch type on computers. I am having to relearn how to type!
    Michael

  • I'm having trouble with something that redirects Google search results when I use Firefox on my PC. It's called the 'going on earth' virus. Do you have a fix that could rectify the vulnerability in your software?

    I'm having trouble with a virus or something which affects Google search results when I use Firefox on my PC ...
    When I search a topic gives me pages of links as normal, but when I click on a link, the page is hijacked to a site called 'www.goingonearth.com' ...
    I've done a separate search and found that other users are affected, but there doesn't seem to be a clear-cut solution ... (Norton, McAfee and Kaspersky don't seem to be able to detect/fix it).
    I'd like to continue using the Firefox/Google combination (nb: the hijack virus also affects IE but not Safari) - do you have a patch/fix that could rectify the vulnerability in your software?
    thanks

    ''' "... vulnerability in your software?" ''' <br />
    And it affects IE, too? Ya probably picked up some malware and you blame it on Firefox.
    Install, update, and run these programs in this order. They are listed in order of efficacy.<br />'''''(Not all programs detect the same Malware, so you may need to run them all to solve your problem.)''''' <br />These programs are all free for personal use, but some have limited functionality in the "free mode" - but those are features you really don't need to find and remove the problem that you have.<br />
    ''Note: If your Malware infection is bad enough and you are mis-directed to URL's other than what is posted, you may have to use a different PC to download these programs and use a USB stick to transfer them to the afflicted PC.''
    Malwarebytes' Anti-Malware - [http://www.malwarebytes.org/mbam.php] <br />
    SuperAntispyware - [http://www.superantispyware.com/] <br />
    AdAware - [http://www.lavasoftusa.com/software/adaware/] <br />
    Spybot Search & Destroy - [http://www.safer-networking.org/en/index.html] <br />
    Windows Defender: Home Page - [http://www.microsoft.com/windows/products/winfamily/defender/default.mspx]<br />
    Also, if you have a search engine re-direct problem, see this:<br />
    http://deletemalware.blogspot.com/2010/02/remove-google-redirect-virus.html
    If these don't find it or can't clear it, post in one of these forums for specialized malware removal help: <br />
    [http://www.spywarewarrior.com/index.php] <br />
    [http://forum.aumha.org/] <br />
    [http://www.spywareinfoforum.com/] <br />
    [http://bleepingcomputer.com]

  • TS3274 my ipad is having trouble with my music... i had recently gotten a new one when i signed into my icloud the music that i had on the original one was not there.... some songs were in fact there but not clickable ( it was there only gray)..anyone kno

    my ipad is having trouble with my music... i had recently gotten a new one when i signed into my icloud the music that i had on the orignal one was not there.... some songs were in fact there but not clickable ( it was there only gray)... i was looking for help on how to get the music on the ipad

    my ipad is having trouble with my music... i had recently gotten a new one when i signed into my icloud the music that i had on the orignal one was not there.... some songs were in fact there but not clickable ( it was there only gray)... i was looking for help on how to get the music on the ipad

  • I am having trouble with my Mac Mini's ethernet connection.   Defining a new network interface shows no ethernet adaptor.  Reloading SL from DVD repaired.  But SL update lost ethernet again.  Will Lion Fix?

    I am having trouble with my mac mini ethernet.  It had been working for weeks after an update to SL 10.6.8.
    Once it went out and i repaired it by defining a new connection from System Preferences ->Network->(left panel service, +).
    But yesterday, after a power up.  my ethernet was not working again. I tried this old trick to repair it, but the interface choices
    listed for '+' a new service did not include Ethernet any more.  And the Utilities->System Profiler->Ethernet Cards shows
    no ethernet available.
    As a last ditch effort i reloaded my original SL from DVD.  (I think it was version 10.6.4 but i could be mistaken on the version).
    The ethernet worked!  But KeyNote wasn't going to work because apparently the version i purchased depends on 10.6.8.
    So I upgraded again to SL 10.6.8 (Plus some other updates like AirPort which i don't use).
    Now the Ethernet is not working again.  I see the same symptoms as before with the Ethernet seeming not installed.
    Is this a problem seen by others?
    Would going to Lion fix the problem?
    Could AirPort actually be the culprit and not SL?
    If i stay with my original SL, would i need to repurchase a version of KeyNote for the older version of SL?

    Have you reset the SMC?
    Shut down the computer.
    Unplug the computer's power cord.
    Wait fifteen seconds.
    Attach the computer's power cord.
    Wait five seconds, then press the power button to turn on the computer.
    While you're at it, resetting the PRAM won't hurt anything and 'might' help is SMC reset didn't work (PRAM does some port control):
    Shut down the computer.
    Locate the following keys on the keyboard: Command, Option, P, and R. You will need to hold these keys down simultaneously in step 4.
    Turn on the computer.
    Press and hold the Command-Option-P-R keys. You must press this key combination before the gray screen appears.
    Hold the keys down until the computer restarts and you hear the startup sound for the second time.
    Release the keys.
    Something else you might try .... you don't say how you're updating to 10.6.8, however, if you're using Software Update, you might try downloading the 10.6.8 combo update, which contains all updates to 10.6. Sometimes, Software Update doesn't work quite right, and installing the combo update fixes that. Download the update from Apple's download site at http://support.apple.com/downloads/ , using Disk Utility repair permissions, apply the combo update, then repair permissions again.

  • I am having trouble with some of my links having images. For example, Foxfire has a picture that looks like a small world. The links in question are blank.

    I am having trouble with my links/websites having images attached to them. The place where the image should be is blank. For example, AARP has an A for its image. My storage website has a blank broken box where the image should be. I forgot I had trouble and had to reset Foxfire, this problem occurred after that reset.

    cor-el,
    Mixed content normally gives the world globe image, unless you are using a theme that uses a broken padlock instead. Maybe the gray triangle means invalid? I came across that in a few themes (what is invalid was not made clear), but those were not using triangle shapes to indicate that.
    I came across that mention in one of the pages you posted:
    * https://support.mozilla.org/kb/Site+Identity+Button
    I cannot attach a screenshot because I have not seen a triangle of any kind in my address bar.

  • I have an Ipod Touch (4th Gen) and I am having troubles with my downloads from purchasing music from the Ipod. On my downloads icon in the Itunes Store (on Ipod) there is a symbol of how many songs I still have waiting to download, but they wont download.

    I have been having troubles with this for months and am extremly tired of not being able to download my songs. I bought these songs off of Itunes as well, so I really hope i can retrieve them. I do not know where to find a personal apple support person yet, does anyone know where to find one on the website?

    See these previous discussions:
    Waiting applications: Apple Support Communities
    Downloading apps stuck on waiting...: Apple Support Communities

  • I am having trouble with iMessage being activated. It has worked up until yesterday and now won't activate and is saying no address in the send and receive section. My number is there but not ticked. Any suggestions on how to fix this?

    I am having trouble with iMessage being activated. It has worked up until yesterday and now won't activate and is saying no address in the send and receive section. My number is there but not ticked. Any suggestions on how to fix this? I have shut down my phone, but still no luck!

    iMessage and FaceTime went down yesterday for some people. Mine is still down. My iMessage is saying the same thing about being activated. Sounds like you are still down too. Ignore the status page that says everything is fine - it lies.

  • I am having trouble with app updates on my iOS 5 iPhone never getting beyond the "waiting" state.

    I am having trouble with app updates on my iOS 5 iPhone never getting beyond the "waiting" state. I have tried signing out/in of my account, rebooting and removing/re-installing the apps.  This started shortly after going to iOS 5 but I am not certain if that is related.  All updates that I try now are stuck in "waiting".  I also tried removing the apps and then installing via iTunes desktop sync with no improvement.  The only thing that I have not tried so far is a restore to a prior iPhone backup.  I have not been able to find anything to indciate what the updates on waiting on.  There is plenty of space on the iPhone (16gb available).  Any suggestions on what to try next? 

    Hello there, Missy.
    First thing I would recommend is to check your downloads queue to make sure there is not an interrupted download per the following Knowledge Base article:
    iTunes: How to resume interrupted iTunes Store downloads
    http://support.apple.com/kb/HT1725
    If your download was interrupted using your iPhone, iPad, or iPod touch
    1. From the Home screen, tap the iTunes app.
    2. For iPhone or iPod touch, tap More > Downloads. For iPad, tap Downloads.
    3. Enter your account name and password if prompted.
    4. Tap the blue download arrow to resume.
    If you can't complete the download on your iOS device, you can download it in iTunes on your Mac or PC and then sync it to your iOS device. You can also transfer purchases from your iPhone, iPad, or iPod to a computer.
    For Apps, you can also try tapping on the application icon to resume the download, as outline in this featured discussion:
    App updates won't download on my...: Apple Support Communities
    https://discussions.apple.com/thread/4111336
    Try tapping the App, so that it changes to Paused instead of Waiting, then tap it again to resume the install.
    Make sure you don't have any paused downloads in other apps either, like the App Store or iTunes Store.
    If that doesn't do it, try resetting or restoring the iPhone.
    via whatheck
    Thanks for reaching out to Apple Support Communities.
    Cheers,
    Pedro.

  • In mail, I am having trouble with my cursor.  It doesn't "land" where I think I'm putting it.  It usually "lands" somewhere below where I "click" it to be.

    In Mail, I am having trouble with my cursor.  When making revisions to what I have already typed, the cursor doesn't "land" where I "click" it to be.  It seems to land somewhere below the spot I click on. It seems to have a mind of its own. 

    Cool handyandy42!
    I'm happy I could be helpful, with solving your problem!
    Also, I notice that you have marked your question as answered, but have not utilized the Helpful or Solved options. That may be intentional, but, if you are not aware of the benefits, of using that function, here is some information.
    When you mark the appropriate posts as Helpful (5 pts) 2 available, or Solved (10 pts) 1 available, you are Thanking the contributors, by awarding them points.
    In threads with multiple replies, it also alerts other readers, to which answers may have been helpful, or solved the issue.
    This info, and more, can be viewed by clicking on
    ? Help & Terms of Use, located under your login name, on all "Discussions" pages.
    Specifically What are question answers?.
    ali b

  • I am an iPad novice and whilst I have managed to set up my personal email, I have having trouble with my business email in that I can receive emails, but am unable to send and the message says 'this email address has been rejected by server'

    I am an iPad novice and whilst I have managed to set up my hotmail account on the iPad - I ham having trouble with my business email (I can receive emails, but cannot send and it says' email rejected by server'

    That sounds like a settings issue to me. Check with your IT depatment to make sure you have it configured properly.

Maybe you are looking for

  • Report table & field problem

    Hi, i created a report vendor aging report. I have to add a field purchase organization at selection-screen and at output. 1)i picked the field ekorg and lifnr from lfm1 table. 2) I made same report but picked ekorg and lifnr from EKKO table. the out

  • Best Usage reporting tool for SharePoint 2013 (onpremises)

    Please suggest me best reporting tool for SharePoint 2013 on premises. Need to get site usage summary for any time in last one year. Need to get library/list usage summary for any time in last one year. etc. How many peak hits and unique no of users

  • How to adjust "activation" underline position on Menu?

    I created a Chapter index and the underlining button Highlight when the chapter is activated is arbitrarely off to one side and not centered. I can offset the text and have it look somewhat purposeful, but better yet how can i simply adjust the under

  • LOV Query --- Urgent Please Help

    Is there any way to hide the %sign from the top field of LOV If not, then any way to hide that field, but not affecting its working and functionality...... Please do reply me if you know something Thanx in advance

  • In Which case Vo extension is not upgrade safe

    Hi all, In Which case Vo extension is not upgrade safe kumar