in Education by
I have a class called myClass which defines post() and get() methods. From index.html, I have a form with an action that calls myClass.post() which grabs some data from the data base, sets a couple variables and sends the user to new.html. now, new.html has a form which calls myClass.get(). I want the get() method to know the value of the variables I got in post(). That is is main point here. I figure the submit from new.html creates a separate instance of myClass created by the submit from index.html. Is there a way to access the "post instance" somehow? Is there a workaround for this? If I have to, is there an established way to send the value from post to "new.html" and send it back with the get-submit? more generally, I guess I don't understand the life of my instances when web-programming. In a normal interactive environment, I know when the instance is created and destroyed, but I don't get that when I'm only using the class through calls to its methods. Are those classes even instantiated unless their methods are called? JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
What you're talking about is establishing a "session". That is, a way to remember the user and the state of their transaction. There are several ways of tackling this, all of which rely on techniques for remembering that you're in a session in the first place. HTTP provides you no help. You have to find some place to save session state on the server, and some place to record session identification on the client. The two big techniques are Use a cookie to identify the session. Seamless and silent. Use a query string in the URL to identify the session. Obvious because you have a ?sessionid=SomeSessionGUID in your URL's. This exposes a lot and makes bookmarking annoying. After the session is cleaned up, you still have this session id floating around in people's bookmarks. In a limited way, you can also use hidden fields in a form. This only works if you have forms on every page. Not always true. Here's how it plays out in practice. GET response. Check for the cookie in the header. a. No cookie. First time user. Create a session. Save it somewhere (memory, file, database). Put the unique ID into a cookie. Respond knowing this is their first time. b. Cookie. Been here recently. Try to get the cookie. FInd the session object. Respond using information in the cookie. Drat. No session. Old cookie. Create a new one and act like this is their first visit. POST response. Check for the cookie in the header. a. No cookie. WTF? Stupid kids. Get off my lawn! Someone bookmarked a POST or is trying to mess with your head. Respond as if it was a first-time GET. b. Cookie. Excellent. Get the cookie. Find the session object. Find the thing you need in the session object. Respond. Drat. No session. Old cookie. Create a new one and respond as if was a first-time GET. You can do the same thing with a query string instead of a cookie. Or a hidden field on a form.

Related questions

0 votes
    I have a class called myClass which defines post() and get() methods. From index.html, I have a ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 7, 2022 in Education by JackTerrance
0 votes
    I have the following HTML/ASP.NET code: Ny test Name: When using the "POST" form post method I ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 15, 2022 in Education by JackTerrance
0 votes
    It's a sad fact of life on Scala that if you instantiate a List[Int], you can verify that your ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 4, 2022 in Education by JackTerrance
0 votes
    @RequestMapping annotation is used to map a HTTP request method (GET or POST) to a specific class or method in the ... which will handle the respective request. A. True B. False...
asked Nov 8, 2022 in Education by JackTerrance
0 votes
    I have a page with a form that posts to salesforce.com's webto Lead service. I am trying to make an ... receiving website can see? Select the correct answer from above options...
asked Feb 8, 2022 in Education by JackTerrance
0 votes
    I have a page with a form that posts to salesforce.com's webto Lead service. I am trying to make an ... receiving website can see? Select the correct answer from above options...
asked Feb 5, 2022 in Education by JackTerrance
0 votes
    I’ve done my btech in information Technology. What should I study (diploma or post graduation) to get a job in cyber security field? Select the correct answer from above options...
asked Dec 23, 2021 in Education by JackTerrance
0 votes
    What are the differences between get and post method?...
asked Sep 28, 2021 in Technology by JackTerrance
0 votes
    I want to get a value from a particular location from list variable. Right now what I see is it only ... from a specified location? Select the correct answer from above options...
asked Feb 8, 2022 in Education by JackTerrance
0 votes
    I want to get a value from a particular location from list variable. Right now what I see is it only ... from a specified location? Select the correct answer from above options...
asked Feb 5, 2022 in Education by JackTerrance
0 votes
    computer a computerized Record Keeping system that enables you to store modify and extract information from a database is known as Select the correct answer from above options...
asked Nov 27, 2021 in Education by JackTerrance
0 votes
    I have an EC2 instance (medium, us-east-1d), and RDS instance (us-east-1a, db.t2.medium). I ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 3, 2022 in Education by JackTerrance
0 votes
    Which of these is a wrapper around everything associated with a reply from an http server? (a) HTTP ... questions and answers pdf, java interview questions for beginners...
asked Oct 25, 2021 in Education by JackTerrance
0 votes
    To get a random variable, ____________. A. (?love|hate|like) B. (*love|hate|like) C. (?:love|hate|like) D. (.*love|hate|like)...
asked Dec 16, 2022 in Education by JackTerrance
...