cancel
Showing results for 
Search instead for 
Did you mean: 

Open JSP

Former Member
0 Kudos

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.

Accepted Solutions (0)

Answers (2)

Answers (2)

kishorg
Advisor
Advisor
0 Kudos

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

Former Member
0 Kudos

Hi Yash and Kishor.

I tried both solutions u give, but i dont have results, with the first the jsp does the same and with the second the vector is empty.

Best regards.

Gregory

former_member182372
Active Contributor
0 Kudos

Hi Gregory,

May be it is not really good idea to use HTTP session as protocol for data transfer from dynpro to jsp. Not sure whether sessoins are same. Try to use transient user attributes instead.

Best regards, Maksim Rashchynski.

Former Member
0 Kudos

Hi Maksim, thx for ur answer.

Can u extend more on "Try to use transient user attributes instead", please?

I dont know well how to do this.

Best Regards.

Gregory.

former_member182372
Active Contributor
0 Kudos

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.

Former Member
0 Kudos

I have a question:

Can i use this in the JSP? i tried to use the user with the instruction request.getRemoteUser() and obtain null.

If so, how can i use it?

how can i know the user of the wdp app into the jsp to use those methods?

I hope u can help me...

Thx and Regards.

Gregory.

former_member182372
Active Contributor
0 Kudos

Hi Gregory,

Try this


//HttpServletRequest request
//HttpServletResponse response
IUser sapUser = UMFactory.getAuthenticator().forceLoggedInUser(request, response);

Best regards, Maksim Rashchynski.

Former Member
0 Kudos

Hi Maksim.

I try with this methods but the vector is still null into the jsp.

I'm using "" or null to the namespace that set/get transient attribute method uses. Is it correct?

Thx a lot.

Best regards.

former_member182372
Active Contributor
0 Kudos

Hi Gregory,

How do you integrate you Web Dynpro and JSP?

Best regards, Maksim Rashchynski.

Former Member
0 Kudos

Hi Maksim.

I tried to integrate webdynpro app and the jsp simply opening an external window.

I thought that the jsp in the external window has the session attributes of the wdp, then before opening the external window i set the attribute to the session.

Thx and Regards.

Gregory.

Former Member
0 Kudos

Please i need some help on that.

Thx.

Regards.

Gregory.

Yashpal
Active Contributor
0 Kudos

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