session Objects

M

morc

hi,

i was wondering if it were possible to put an array of ints as a
session object.

session.setAttribute(String,Object);

i can't figure out how to get an array of ints into where it says
Object.

and when i do how do i retrieve it?

???? = session.getAttribute(String);

if you know how please help me.
thanks alot
-morc
 
O

Oliver Wong

morc said:
hi,

i was wondering if it were possible to put an array of ints as a
session object.

session.setAttribute(String,Object);

i can't figure out how to get an array of ints into where it says
Object.

and when i do how do i retrieve it?

???? = session.getAttribute(String);

if you know how please help me.
thanks alot

Take your array and convert it to an ArrayList. Then store the ArrayList
in the session.

When you retrieve the object out, it'll be an ArrayList. Convert it back
to an array, if nescessary.

- Oliver
 
L

L. Beaux Al-Catraz III

Oliver Wong took the said:
Take your array and convert it to an ArrayList. Then store the ArrayList
in the session.

When you retrieve the object out, it'll be an ArrayList.

It'll be an object. He'll have to cast it to the ArrayList first. Then
he can do the thing you said.

Convert it back
to an array, if nescessary.

arraylistName.toArray() will give you an object array, so you'll have to
cast again once you get the object from the array.

--
L. Beaux Al-Catraz III
mhm31x9 Smeeter#29 WSD#30
sTaRShInE_mOOnBeAm aT HoTmAil dOt CoM

NP: "Jellyroll" -- Blue Murder

"Now, technology's getting better all the time and that's fine,
but most of the time all you need is a stick of gum,
a pocketknife, and a smile."

-- Robert Redford "Spy Game"
 
M

morc

thanks

is there anyway to detect the end of a session?

for example call a function once the session is over?

-morc
 
L

L. Beaux Al-Catraz III

morc said:
thanks

is there anyway to detect the end of a session?

When a browser hits your site, session starts.

When the browser leaves, session ends.

That's why you need cookies or whatever to get the session id back, so
you can resume it.
for example call a function once the session is over?

-morc

--
L. Beaux Al-Catraz III
mhm31x9 Smeeter#29 WSD#30
sTaRShInE_mOOnBeAm aT HoTmAil dOt CoM

NP: "Jellyroll" -- Blue Murder

"Now, technology's getting better all the time and that's fine,
but most of the time all you need is a stick of gum,
a pocketknife, and a smile."

-- Robert Redford "Spy Game"
 
R

Roedy Green

When a browser hits your site, session starts.

When the browser leaves, session ends.

The browser won't tell the server though about its leaving, right?

you just have to time out.
 
O

Oliver Wong

Roedy Green said:
The browser won't tell the server though about its leaving, right?

you just have to time out.

I don't know about JSP, but in the PHP world, the page is only sent to
the browser once the code has finished executing. So timing-out in the
traditional sense is not even an option, as by the time the user *STARTS*
downloading the HTML, the script has already finished executing.

What is usually done in PHP is to check on the *next* request whether
there's any left-over work to be done from the previous request. Note that
this "next request" might not be from the same client as the one that made
the previous request.

Garbage collection for session files, for example, is usually randomly
done 1 out of 10 times at the beginning of every request. So on average,
after every 10 requests made, the PHP engine will search the session
directory and delete all the session files older than, say, 20 minutes, for
ALL users; not just the user who made the request that invoked the PHP
engine in the first place.

- Oliver
 
T

trippy

Roedy Green said:
The browser won't tell the server though about its leaving, right?

I don't think so but I could be wrong.
you just have to time out.

This doesn't sound right. Server will spawn an instance of servlet, then
the servlet handles the requests that come in. Get the request, give the
info, done. (Obviously, this is greatly simplified)

--
trippy
mhm31x9 Smeeter#29 WSD#30
sTaRShInE_mOOnBeAm aT HoTmAil dOt CoM

NP: "Jellyroll" -- Blue Murder

"Now, technology's getting better all the time and that's fine,
but most of the time all you need is a stick of gum,
a pocketknife, and a smile."

-- Robert Redford "Spy Game"
 

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,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top