Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / February 2006

Tip: Looking for answers? Try searching our database.

session Objects

Thread view: 
morc - 08 Feb 2006 19:16 GMT
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
Oliver Wong - 08 Feb 2006 19:32 GMT
> hi,
>
[quoted text clipped - 12 lines]
> 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. Beaux Al-Catraz III - 08 Feb 2006 20:18 GMT
> > hi,
> >
[quoted text clipped - 17 lines]
>
>     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.

Signature

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"

morc - 08 Feb 2006 20:41 GMT
thanks

is there anyway to detect the end of a session?

for example call a function once the session is over?

-morc
L. Beaux Al-Catraz III - 08 Feb 2006 20:58 GMT
> 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

Signature

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"

Roedy Green - 09 Feb 2006 06:53 GMT
On Wed, 8 Feb 2006 14:58:28 -0600, L. Beaux Al-Catraz III
<silverbells@tacoshells.com> wrote, quoted or indirectly quoted
someone who said :

>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.
Signature

Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.

Oliver Wong - 09 Feb 2006 15:10 GMT
> On Wed, 8 Feb 2006 14:58:28 -0600, L. Beaux Al-Catraz III
> <silverbells@tacoshells.com> wrote, quoted or indirectly quoted
[quoted text clipped - 7 lines]
>
> 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
trippy - 09 Feb 2006 20:52 GMT
> On Wed, 8 Feb 2006 14:58:28 -0600, L. Beaux Al-Catraz III
> <silverbells@tacoshells.com> wrote, quoted or indirectly quoted
[quoted text clipped - 5 lines]
>
> 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)

Signature

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"



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.