Can Javascript access request object? Need to persist data

N

news.rcn.com

How can I access the request and response object for a page using
javascript. I want to stick some data on with something like
request.setAttribute( "User's choice for later use" ).
I can't seem to find a reference to request or response objects in
JavaScript either in Google Groups or O'Reilly's "JavaScript the Definitive
Guide" (surely it should be in the latter, huh?)

I know I could use a hidden form element but the data would be a Parameter
and not stay around long enough; the user may recall the data much later in
the session. I'd rather not have to gather the parameter and reattach it as
an Attribute on the server everytime a page is submitted with data that need
to persist over the invocation of many unpredictable pages.

Thanks for your suggestions.

jim

p.s. I'm avoiding cookies so things will still work if cookies are
disabled.
 
T

Tim Williams

There's no "request" or "response" object that I know of client-side.
These are pretty much server-side constructs.

Maybe you would be better off taking some time to describe exactly
what your environment is and what you need to do. It seems like you
need to persist some info across multiple pages, so a server-side
session parameter sounds like a good bet (particularly if you want to
be cookie-independent).

Tim.
 
N

news.rcn.com

Yes, persisting info across multiple pages is exactly what I want to do and
a session parameter would do the trick excellently well. The issue is how to
get the info on the session parameter.

Ideally, in my opinion, the client-side page where the info in solicited
from the user should do the persisting; this way no one else need be
involved.

If this can't be done, then, on the server side, I'd have to examine each
request for a new page to see if some user-inputted info is attached and
then deal with it. Or perhaps have the client request be forwarded to a
special page (actually servlet) which would persist the info then forward to
the page that the client 'really' wants next.

All in all, more complicated then having the guy that wants to save
something save it and be done with it. Sounds like cookies may be the easy
way and then deal with users with cookies blocked when the issue comes up.

Thanks for your help.
 
W

web.dev

news.rcn.com said:
How can I access the request and response object for a page using
javascript. I want to stick some data on with something like
request.setAttribute( "User's choice for later use" ).
I can't seem to find a reference to request or response objects in
JavaScript either in Google Groups or O'Reilly's "JavaScript the Definitive
Guide" (surely it should be in the latter, huh?)

I know I could use a hidden form element but the data would be a Parameter
and not stay around long enough; the user may recall the data much later in
the session. I'd rather not have to gather the parameter and reattach it as
an Attribute on the server everytime a page is submitted with data that need
to persist over the invocation of many unpredictable pages.

Thanks for your suggestions.

jim

p.s. I'm avoiding cookies so things will still work if cookies are
disabled.

There is no Request object in javascript per se, but you can do some
things that the Request object does. For example, a Request object in
ASP can be used to manipulate cookies, read the QueryString, and gather
form data.

You can do all three of these with javascript. Since you're wanting to
pass information around to each page without using cookies, you could
probably use a mixture of hidden forms and the querystring. However
with the QueryString, you can only pass around GET data, as client-side
javascript cannot gather POST data for obvious reasons.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top