on 02-09-2006 9:05 PM
Hi all.
I'm trying to open a jsp file and pass a collection of objects in the session as the following code:
Vector v = new Vector();
for(int i=0; i<[SOME SIZE]; i++){v.add(<OBJECT i>);}
HttpServletRequest req = ((IWebContextAdapter)WDWebContextAdapter.getWebContextAdapter()).getHttpServletRequest();
req.getSession().setAttribute("vector",v);
Then in the JSP i'm doing this:
<%
java.util.Vector v = (java.util.Vector)session.getAttribute("vector");
try{
[PROCESS THE VECTOR]
} catch(Exception e){[HANDLE EXCEPTION]} %>
Well the exception catched is that the vector is null, the session hasnt attributes.
What can i do?
Best Regards
Gregory.
Hi Gregory,
just set the required vector in session like this,
Vector v = new Vector();
for(...)
{
//fill values in vector.
}
request.getSession().setAttribute("vectorBean",v);
then in JSP page u can access this like this,
<b><jsp:useBean id="vectorBean" scope="session" class="java.util.Vector" /></b>
for(int c=0;c<vectorBean.size();c++)
{
//loop through each element
}
Regards
Kishor Gopinathan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Gregory,
Check this http://media.sdn.sap.com/html/submitted_docs/60_sp2_javadocs/ume/com/sap/security/api/IUser.html#set..., java.lang.String, java.lang.Object)
<i>
getTransientAttribute
setTransientAttribute
</i>
Best regards, Maksim Rashchynski.
Hi Gregory,
instead of req.getSession().setAttribute(....);
use req.getSession(true).setAttribute(.....);
because this method return an httpsession object even when a sessio oject is not assocaiated with an request ... i hope it will solve ur problem.
Regards,
Yash
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
76 | |
9 | |
8 | |
7 | |
6 | |
5 | |
5 | |
5 | |
5 | |
5 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.