cancel
Showing results for 
Search instead for 
Did you mean: 

unable to get values from Jspdynpge class component to jsp

Former Member
0 Kudos

hello,

I am using the jspdynpage model with out bean.I am retrieving the user info and i am trying to pass these values to jspdynpage using session object.I am not able to pass the values to jsp page.It tried doing that using context object too.it gives me error.And also how to pass the values in jsp to javascript.help me understand where I am going wrong.

Here is the code i am using:

package com.PS.BDS;

import com.sapportals.htmlb.*;

import com.sapportals.htmlb.enum.*;

import com.sapportals.htmlb.event.*;

import com.sapportals.htmlb.page.*;

import com.sap.security.api.IUser;

import com.sapportals.portal.htmlb.page.*;

import com.sapportals.portal.prt.component.*;

public class eg3_JspDyn extends PageProcessorComponent {

public DynPage getPage(){

return new eg3_JspDynDynPage();

}

public static class eg3_JspDynDynPage extends JSPDynPage{

public void doInitialization(){

}

public void doProcessAfterInput() throws PageException {

IPortalComponentRequest request = (IPortalComponentRequest) this.getRequest();

IPortalComponentResponse response;

IUser myUser = request.getUser();

//IUser myUser = userFactory.getUser(request.getUser().getUserId());

//String logonID = IPrincipal.getUniqueID();

String logonID = myUser.getUid();

String mail= myUser.getEmail();

//String lname =

//String firstname =

//String name = myUser.getUniqueName();

String city =myUser.getCity();

//response.write("User Id" + logonID);

request.getComponentSession().putValue("LogonID", logonID);

}

public void doProcessBeforeOutput() throws PageException {

this.setJspName("eg3_jsp.jsp");

}

}

}

Jsp:

<%

componentRequest.getComponentSession().getValue("myText").toString(); %>

<a href="javascript:SendEmail()">

<img src="C:\Documents and Settings\10095594\Desktop\eNewsletter.gif"

width="144" height="50">

</a>

<body><script type="text/javascript">

</script></body>

portalapp.xml

<?xml version="1.0" encoding="utf-8"?>

<application>

<application-config>

<property name="SharingReference" value="com.sap.portal.htmlb"/>

</application-config>

<components>

<component name="eg3_JspDyn">

<component-config>

<property name="ClassName" value="com.PS.BDS.eg3_JspDyn"/>

<property name="ComponentType" value="jsp"/>

<property

name="SecurityZone"

value="com.sap.pct.pdk/low_safety"/>

<property name="JSP" value="pagelet/eg3_jsp.jsp"/>

</component-config>

<component-profile/>

</component>

</components>

<services/>

</application>

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hello,

I got out of this problem.the rean is really silly.I should put my logic in eighter init or PBO instead I put that in PAI.

I have one more question

<%componentRequest.getComponentSession().getValue("logonID").toString();%>

the above code we use to get the login value from the session is not displaying in jsp page.I i am sending the value to the session from the component class and able to retrieve the same vale from the session,so the value is stored in the session.I not sure whether the above code is getting the vale or not.If so how to display that and how can that value be passed to java script suppose if we click the hyperlink as an example.

Thanks,

suresh_krishnamoorthy
Active Contributor
0 Kudos

Hi Sriram,

Your Portalapp.xml should be like this

<?xml version="1.0" encoding="utf-8"?>

<application>

<application-config>

<property name="SharingReference" value="com.sap.portal.htmlb"/>

</application-config>

<components>

<component name="eg3_JspDyn">

<component-config>

<property name="ClassName" value="com.PS.BDS.eg3_JspDyn"/>

</component-config>

<component-profile>

<property name="tagLib" value="/SERVICE/htmlb/taglib/htmlb.tld"/>

</component-profile>

</component>

</components>

<services/>

</application>

See this link for compelete code

http://help.sap.com/saphelp_nw04/helpdata/en/95/cfa441cd47a209e10000000a155106/frameset.htm

Regards, Suresh KB

former_member394902
Contributor
0 Kudos

Hi sriram,

it is not necessary to pass the logged in user to the jsp page. The jsp page has the request object from which you can get the user

put this code in the jsp page


<%!
private String getLogonInfo(IPortalComponentRequest request){
IUserContext userContext = request.getUser();
	if (userContext != null){
		String firstName = userContext.getFirstName();
		/*you can retrieve other values also*/
	}
}
%>

<%
String firstName = getLogonInfo(componentRequest);
%>

in your jsp use
<%=firstName%>

hope this helps.

Akhilesh

Former Member
0 Kudos

Hi Akhilesh,Suresh,

Thanks for your reply.Your answers were helpful for getting my work done.

Thanks.

Former Member
0 Kudos

The error I am getting is "exception occured while processing the request".

thanks.