Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

multiple session atributes

843835Mar 12 2003 — edited Mar 12 2003
how can i put multiple atribute's in one session and collect them after i load another page

Comments

843835
You can use..

session.setAttribute("ObjectName", Object);

to set as many attributes into the session as you want,
and you can use..

(Object)session.getAttribute("ObjectName");

to get the object back out. For Jsps, useBean tags are
the best method.

<jsp:useBean id="BeanID" class="com.package.Whatever" scope="session" />

843835
ok this is my code now but it still does not work:

session = request.getSession(true);
(ip)session.setAttribute("ip", ip);
(naam)session.setAttribute("naam", jnaam);
(bedrijf)session.setAttribute("bedrijf", jbedrijfID);
(afdeling)session.setAttribute("afdeling", jafdeling);

_____redirirect_______

String jip = (ip)session.getAttribute("ip");
String jnaam = (naam)session.getAttribute("naam");
String jbedrijf = (bedrijf)session.getAttribute("bedrijf");
String jafdeling = (afdeling)session.getAttribute("afdeling");

tnx btw for teh quick response
843835
ok this is my code now but it still does not work:

session = request.getSession(true);
(ip)session.setAttribute("ip", ip);
(naam)session.setAttribute("naam", jnaam);
(bedrijf)session.setAttribute("bedrijf", jbedrijfID);
(afdeling)session.setAttribute("afdeling",
jafdeling);

_____redirirect_______

String jip = (ip)session.getAttribute("ip");
String jnaam = (naam)session.getAttribute("naam");
String jbedrijf =
(bedrijf)session.getAttribute("bedrijf");
String jafdeling =
(afdeling)session.getAttribute("afdeling");

tnx btw for teh quick response
ok first of all you don't need to cast the setAttribute();
so do like this:
session.setAttribute("ip", ip);
session.setAttribute("naam", jnaam);
session.setAttribute("bedrijf", jbedrijfID);
session.setAttribute("afdeling", jafdeling);

to fetch them in a jsp do this:

String jip = (String)session.getAttribute("ip");
String jnaam = (String)session.getAttribute("naam");
String jbedrijf =(String)session.getAttribute("bedrijf");
String jafdeling =(String)session.getAttribute("afdeling");


veel geluk,

greetings
843835
het werkt ;)

heel erg bedankt ben er erg mee geholpen!!!
1 - 4
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Apr 9 2003
Added on Mar 12 2003
4 comments
91 views