Using Cookies to remember inputs

Hi all,
I am using JSP and Javascript in my application. In my application i have created a dropdown list using java script and that is dynamic meaning that you can create as many drop down list as you want to choose different values.
Now i want to remember all the values that a particular user has selected last time he visited meaning that the number of dropdown list he created and also the data he selected in those drop down lists.
Can anyone please give me some code samples how can i do that.
Thanks

Can anyone please give me some code samples how can i do that.And what prevents you from searching the web ?

Similar Messages

  • Using cookies to remember the last 2 links visited

    Hey everyone,
    I am trying to use learn JSP and cookie. I am making a webpage, and it is suppose to remembers the last 2 links selected from the website.
    Basically, there are a few radio buttons. The user is to pick one, press submit. I am trying to write a cookie to "remember" that action so that the next time that user comes, there should be a link that says these are the last 2 pages visited.
    Having not much JSP experience, I would like some assistance in building this kind of a website. It is very simple (Just a table with 2 columns - left for menu, right for navigation).
    I was wondering if someone could help me with this.
    Thanks in advance.

    Can anyone please give me some code samples how can i do that.And what prevents you from searching the web ?

  • How do I use cookies to control which part of the timeline to play from?

    Hi there,
    I have created an animation with Adobe Edge. My site uses Concrete5 and I am pulling in the Edge content into an IFRAME on my home page (there my be a better way to do this and I'm open to suggestions). I want the animation to play from the start when someone first visits the site, but if during their browser session they navigate back to the home page, I want the animation to only play a shorter segment of frames near the end.
    My question is, how do I use cookies to acheive this? I'm new to javascript/jquery.
    I've included the following code on compositionReady, (found in another post on this forum) but don't have a clue how to continue...
    // insert code to be run when the composition is fully loaded here yepnope(   {     nope:[       '/js/jquery.cookie.js'     ],   complete: init   } ); function init() { //create your cookie's initial values here } 
    My temp site is here - http://79.170.40.43/nutcrackerdesign.co.uk/
    On revisting the homepage, I only want to play from when the green 'How can we help?' button drops in.
    Many thanks!
    Russ

    Hi, Russ-
    I found this article, which seemed really helpful in describing how cookies work in JavaScript:
    http://www.quirksmode.org/js/cookies.html
    Remember that JS works just fine within Animate, so on your compositionReady, you can read your cookie and then set the play based on that.  You should probably uncheck the autoplay for your Stage and control the play of your Stage from the compositionReady.
    Good luck!
    -Elaine

  • Using cookies and JavaScript to create a page to page timer.

    I have long wanted to be able to measure the time it takes to get from one page to another.  While reading in my JavaScript reference the other day, I came across cookies.  I've long known about cookies but have never used them.  The thing that looked attractive was that you can access cookies from both JavaScript and CF.
    So I put together the procedures to store the "start time" (startTimeP8D) for the transition and activated it on the onUnload event of a 1stpage.  After a few rewrites I got it working.   Here is the JavaScript to do that: it consists of two functions: doTimer which is the input section and setCookie, which writes to the cookie.  Not the two numbered alert statements.
    doTimer - results for "start" from the doTimer function called from page 1 when it unloads. (See doTimer below)
         Please note that the two startTime8D values are the same immediately after they are stored.
    On the 2nd page in the sequence, I run the corresponding code to determine the "end time", compute the delta and write it out to the page.  It didn't all run on the first try, but it now seems to be running without a crash, which can be misleading.
          second set of outputs from page 2:    
         Please not that while the endTimeP8D match, the startTimeP8D value no longer matches the previously stored value. 
    There is one major hitch in the get along which has me stymied:  As you can see, when you compare the startTimeP8 in the setCookie – results above and the "startTimeP8" in the doTimer results below the startTimeP8 is not the value that I wrote to the cookie @ unload of page 1.  I have checked and checked and do now see anywhere that the startTimeP8D value is being overwritten.  Based upon my limited experience with JavaScript cookies, it seems to me that you get an entry for each time you set the cookie.  So I would expect to see to startTimeP8D entry for each setCookie event, not a different value.
         The result of the failed computation is shown on the bottom of the page.  As you can see, the Total Elapsed Time is negative, which is never a good sign.  The other time shown, Page build time, is the run time from the server.  The whole purpose is to be able to show folks that the reason the code might be show is because of their overloaded network and not our code.  We had one client whose had users running on 56k modems.  It was so slow their VPN software was timing out!!!  Still the had the never to blame us!!!
    I am using SQLServer 2005, CF8, IE8 on W7. 
    I'm not married to this way of doing this so if anyone has a better/easier way of doing a "page to page timer", I'm up for it.  I'd prefer to fix this one since I've been working on it for the past 3 days.
    Thanks in advcance for your help.
    Len, PHRED SE

    Here it is with no JQuery or console logging calls using cookie utility functions found here:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
           "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
         <title>Test JavaScript Page Load Timer</title>
         <script>
              window.onload = function(){
                   var previousPageUnload = getCookie('unloadTime');
                   if(previousPageUnload){
                        var d = new Date();
                        var loadTime = d.getTime() - previousPageUnload;
                        alert(loadTime + 'ms');
              window.onunload = function(){
                   var d = new Date();
                     setCookie('unloadTime',d.getTime());
              function setCookie(c_name,value,expiredays) {
                   var exdate=new Date();
                   exdate.setDate(exdate.getDate()+expiredays);
                   document.cookie=c_name+ "=" + escape(value) + ((expiredays==null) ? "" : ";expires="+exdate.toUTCString());
              function getCookie(c_name) {
                   if (document.cookie.length>0) {
                     c_start=document.cookie.indexOf(c_name + "=");
                     if (c_start!=-1)
                       c_start=c_start + c_name.length+1;
                       c_end=document.cookie.indexOf(";",c_start);
                       if (c_end==-1) c_end=document.cookie.length;
                       return unescape(document.cookie.substring(c_start,c_end));
                   return null;
         </script>
    </head>
    <body>
         <h1>Test JavaScript Page Load Timer</h1>
    </body>
    </html>
    Note that overwriting global window events like this is not a good idea, which is why I used JQuery in my earlier example. I strongly suggest you look at JQuery or one of the other JS libraries (YUI, etc.) to help with event handling. I'll leave it at that as this is getting into JavaScript development, not really on topic for a ColdFusion forum.

  • Using Cookies

    Hi there
    I have a report template, inside of which is a div containing drop down boxes. I want to use a button to hide/show the div.
    The code to do that is quite simple, however, I want to be able to 'remember' the view state of the div with subsequent page refreshes ( as happens when a value is selected from the drop down ).
    I thought I could use client-side cookies to achieve this, and for the most part this works.
    However, the first time I set the cookie, it doesn't seem to save the value.
    So, the process behind the scenes, is as follows:
    1. Enter the page for the first time ... cookie doesn't exist and div is hidden
    2. Click on the SHOW button, which sets the cookie to visible, and displays the div.
    3. Select a value from one of the dropdowns in the div, which reloads the page.
    4. As the page loads, the cookie should be read and the div display, but I find that the cookie is null or doesn't exist. If I now follow steps 2 and 3 again, next time the page loads, the cookie is read.
    So ... the cookie doesn't seem to be set on the first action, but does work correctly on subsequent actions ... very confusing ??
    Any ideas?
    Cheers,
    Andrew

    Hi,
    You can find the info on how to use cookies here:
    http://java.sun.com/developer/onlineTraining/Programming/JDCBook/aucserv.html
    Hope this helps you
    Cheers
    Giri :-)
    Creator Team

  • How can I use cookies in Web Content Overlays?

    I have a survey created with Google Docs. It uses cookies to tell if a user has already submitted an answer to a survey.
    It seems to me that these cookies are not stored with web content overlays (I've used the direct URL to the survey as input).
    Am I right? Is there a way to make the cookie thing work?
    br, Simon

    Hi,
    Is this procedure still available in 9iAS and RDBMS 8.1.6 ? I am trying to get it to work, and I keep getting "ORA-00942: table or view does not exist". The owner of this package is "SYS". I even tried prefixing the table name in the SQL string passed to calendarprint with the owner, and it still gave me this error. Does this have anything to do with the invoker rights model ? I need to set up a web calendar and would love to use this functionality...
    What gives ?
    Any help would be appreciated.
    Thanks you

  • Remember input history in webdynpro

    Hi
       My requirement is how to remember input field history in webdynpro.  for example in my screen have two input field
    1.login id 2.password
    first: xxxxx person log into..........
    second: yyyyy person log into............
    if i press space bar i wants login history like: xxxxxx
                                                                           yyyyyy
    like : gmail or yahoo.
    Thanks

    Hi,
    Thomas Jung
    Posts: 7,249
    Registered: 1/11/06
    Forum Points: 19,080 
       Re: Auto-Complete for Input Fields in WD4A   
    Posted: Aug 25, 2009 4:16 PM    in response to: Björn von Staden           Reply 
    The browser has a field input history mechanism, however it is disabled on purpose in Web Dynpro because the way that the browsers store this information is insecure.
    In NetWeaver 7.02 we will introduce the concept of SuggestValues. This is not history, but intellegent value suggestion based upon domain or search help values. It completes as you type using an AJAX call back to the server to retrieve the values.
    Thanks,
    -Syed.

  • Use cookies or sessions or what?

    I am using frames on Web Site One, with a frame on Web Site
    One pointing to Web Site Two (I own both web sites).
    Problem: Web Site Two needs remember variables in the Web
    Site Two frame displayed on Web Site One.
    When I use cookies on Web Site Two, they work fine when
    actually on Web Site Two. But cookies will not work in the Web Site
    Two frame on Web Site One.
    I have tried using cfcookie with the domain setting, but it
    doesn't work... probably because they are completely different
    URLs.
    I have tried using session variables, which also work on Web
    Site Two when on that web site, but not when accessing Web Site
    Two's pages in a frame on Web Site One.
    Is there a way to retain variables within a frame on Web Site
    One that is pointing to a completely different URL? Again, I have
    complete access to the coding on both web sites.

    Only if you pass the variable in a url in that frame.
    Sessions and Cookies (
    in many cases the same thing) are domain specific, and not
    only would this not be allowed security-wise by the browser, but CF
    will attempt to stop it as well.
    What you are attempting is basically cross-site scripting.
    Passing a variable to the url of each fram ewould be the only
    way to send the same variable to a completely different website.

  • PO creation using LSMW through batch input method

    Hi, I am new to working with LSMW and i have completed a project for creating purchase orders using the direct data input method. I need to do the same using batch input method, however in the maintain structure relationship step, it is only allowing me to assign one structure to the recording that i have done, however in po creation we need separate (nested) structure for header and line item, could anybody help me past this please?

    Hi Rudra!
    OK, now you just know, why you have only one line, not multiple PO item lines. To get a dynamic number of items, you need a complex program - just like standard direct input.
    If you need a field, which is not part of this program, don't try to write your own program for batch input - it's just to much work before you have a good result.
    You can use Bapi method instead with BAPI_PO_CREATE1. This can handle a lot of fields and there is some documentation available how to fill the Bapi.
    If this looks to complicated in the first moment, think about creation of POs via direct input and a small batch recording to change your additional field(s) afterwards. (You can select EKPO table to generate list of 'wrong' migrated orders for input in LSMW.) Use field 'Item' in the bottom of ME22 to position your desired line in first screen line, just change one PO-line after one other (every time a 'save' -> no problem with different number of lines / PO).
    Regards,
    Christian

  • Using more than one input device at the same time

    Is it possible to use more than one input device at the saem time in logic express. For example I have a fire wire input device and a usb input device can I get Express to recognize both of these at once and so have a total of 4 ins which would be great since Im transfering tracks off my ADAT and it would be less track to have to line up.
    Thanks

    Hi,
    yes, it should be possible by creating an aggregate device. Google for it or search this forum. There are many tutorials how to set it up.
    Have fun!
    Fox

  • How to use RFBIBL00 as direct input in LSMW

    Can any one Please help how to use RFBIBL00 as direct input in LSMW ? How should be structure Same level or subordinate level as I will be having single text file ?
    I have around 15 fields with me
    BKPF
    STYPE     C     1
    BLDAT     C     10
    BLART     C     2
    BUKRS     C     4
    BUDAT     C     10
    XBLNR     C     10
    WAERS     C     3
    XPRFG     C     1
    XMWST     C     1
    BSEG
    STYPE     C     1
    NEWBS     C     2
    DMBTR     C     10
    KOSTL     C     10
    SGTXT     C     10
    PRCTR     C     10
    NEWKO     C     10
    MWSKZ     C     2
    Thanks and Regards
    Guru

    Hi,
    look testabap RFBIBLT0, which creates testfile
    A.

  • Using JSP parameters as input in a JavaScript function

    hey
    I have a JavaScript function, which I call with JSP parameters.
    The function call looks similar to:
    <button onclick="myFunction(<%= jspParameter%>);"> </button>
    However, this JavaScript function is called from a jsp page, which is asynchronously refreshed upon a click of the button.
    The problem is that the JavaScript function does NOT function when I click the button for the first time (or maybe it functions, but with the old value of the jspParameter).
    Only after the second click it starts taking the jspParameter.
    Can you please tell me how to properly get the jspParameter as input in my case....
    thank you

    I'm sorry, you're right - I didn't give enough details.
    My whole page consists of several jsp-s.
    The jsp, from which I call the JavaScript function is just one part of the whole page. I'll call it partToBeChanged.jsp.
    When I press the button, the partToBeChanged.jsp should refresh asynchronously and call the JavaScript function using the new jsp parameter as input.
    To be more precise, here is roughly how myFunction looks like (JavaScript):
    function myFunction(url, jspParam) {
         var XMLHttpRequestObject = false;
         if (window.XMLHttpRequest) {
              XMLHttpRequestObject = new XMLHttpRequest();
         } else if (window.ActiveXObject) {
              XMLHttpRequestObject = new ActiveXObject("Microsoft.XMLHTTP");
         if (XMLHttpRequestObject) {
              XMLHttpRequestObject.open("GET", myServlet + url, true);
              XMLHttpRequestObject.onreadystatechange = function() {
                   if (XMLHttpRequestObject.readyState == 4 && XMLHttpRequestObject.status == 200) {
                        //plug server response in the target place.
                        //The target is an id of a division, which holds the partToBeChanged.jsp page
                        //The server itself uses RequestDispatcher to direct the response to the partToBeChanged.jsp     
                        //NOTE: partToBeChanged is only a part of the whole HTML page, which is refreshed dynamically               
                        document.getElementById('target').innerHTML = XMLHttpRequestObject.responseText;
                        //changes the content of a div, which is IN ANOTHER .jsp fragment (different than partToBeChanged.jsp)
                        y = document.getElementById("div_to_change");
                        y.innerHTML = jspParam;
              XMLHttpRequestObject.send("");
    }the jspParam is a java object, initialized in the servlet and used in partToBeChanged.jsp
    To summarize: the servlet dispatches the response to the partToBeChanged.jsp page, which uses the jspParam as input for myFunction, and myFunction tries to change the content of the "target" div accorting to the jspParam. However it changes as expected only after the second button click.
    Thanks a lot for any help....

  • How to use cookies in jsp

    Hi all,
    I'm new to jsp, please let me know how to use cookies with jsp.
    I have three web applications, in run time I have to switch from one application to another application based on single login page. I have taught cookies are one of the solution. But while I'm googling I unable to get such a good material.
    please give some examples,
    Thanks in advance.
    achchayya

    Read a cookie in jsp
    HttpSession session = request.getSession();
    Cookie cookie_session = getCookie(request, "COOKIENAME");
              if (cookie_session == null) {
                   sesID = session.getId();
              } else {
                   sesID = cookie_session.getValue();
              }or
    get all cookie in the browser
    This gets all the cookies and according to the cookie name given u can get the cookie value
    Cookie[] cookies = request.getCookies();
              if (cookies != null) {
                   for (int i = 0; i < cookies.length; i++) {
                        if (cookies.getName().equals(cookieName))
                             return cookies[i];
                   }but i am not sure if this works for ur requirement try and see                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • How to use cookies in struts

    hai
    iI am new to struts. I want to get value in text field from one form to another using cookis in struts, can any one help me?, please...

    To write a cookie in Struts, you create one and add it to the response object. (response.addCookie(cookie)).
    To read it, you use the bean:cookie tag.
    As to use cookies to get a given value from one form to another, there might be better ways, like using request attributes.
    You might be better off keeping those cookies in the jar, after all.

  • How to use Cookies in Web DynPro?

    Hello,
    Is there a way to use Cookies in Web DynPro like a regular Servlet uses in it's response Object?
    If yes, I could use a code example...
    Roy

    Hi Roy,
    1. This will create a Request Objec containing all the client's request just like in a regular Servlet or does it have special considerations I should worry about?
    A: If you have portal and webdynpro components, both have to use the same runtime. If you are using only webdynpro components then you can use the "Task" class. But it is a non-standard API.
    Task.getCurrentTask().getWebContextAdapter().getHttpServletRequest()
    2. Where do you recommend putting this statement? I assume at the wdDoInit() method right?
    A: Don't put this statement in the doInit(), if you are handling some event within the component and refreshes the view, your doInit() will not get executed.
    3. Is there a Response object I can create as well?
    A:
    HttpServletResponse response =((com.sap.tc.webdynpro.services.sal.adapter.core.IWebContextAdapter) WDWebContextAdapter.getWebContextAdapter()).getHttpServletResponse()
    Regards,
    Santhosh.C

Maybe you are looking for