cancel
Showing results for 
Search instead for 
Did you mean: 

JSP Dynpage development

former_member1279004
Participant
0 Kudos

Hi,

I am using JSPDynpages and am trying to save a value in my bean and get access to this value on my JSP page. I have not been able to get the value from my bean to the jsp page any thoughts on what I may be doing wrong would be appreciated.

Below is the code I am working with

Mike

public void doProcessBeforeOutput() throws PageException

{

myBean myBean = new myBean();

((IPortalComponentRequest)getRequest()).getServletRequest().setAttribute("myBean", myBean);

// fill your bean with data here...

myBean.setBappiReturn( "Hello World");

this.setJspName("JSPTest.jsp");

}

-


<%@ taglib uri="tagLib" prefix="hbj" %>

<%@ page import="com.sapportals.portal.prt.runtime.PortalRuntime" %>

<%@ page import="com.sapportals.portal.prt.resource.IResource" %>

<jsp:useBean id="myBean" scope="request" class="myBean.myBean" />

<hbj:content id="myContext" >

<hbj:page title="PageTitle">

<hbj:form id="myFormId" >

<%= myBean.getBappiReturn()%>

</hbj:form>

</hbj:page>

</hbj:content>

-


import java.io.Serializable;

public class myBean implements Serializable

{

public String bappiReturn = "";

/**

  • @return

*/

public String getBappiReturn() {

return bappiReturn;

}

/**

  • @param string

*/

public void setBappiReturn(String string) {

bappiReturn = string;

}

}

-


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

<application>

<application-config>

<property name="PrivateSharingReference" value="com.sap.portal.htmlb,com.sap.portal.themes.lafservice,com.sap.portal.navigation.service,com.sap.portal.navigation.helperservice,com.sap.portal.pagebuilder,jco,jcoclient"/>

</application-config>

<components>

<component name="JSPProject">

<component-config>

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

<property name="ClassName" value="JSPProject.JSPProject"/>

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

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

</component-config>

<component-profile>

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

</component-profile>

</component>

</components>

<services/>

</application>

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

HI Mike,

in the public void doInitialization()----

/***********Setting of the Bean object***************/

IPortalComponentSession componentSession =

((IPortalComponentRequest) getRequest()).getComponentSession();

Object o = componentSession.getValue("myBean");

if (o == null || !(o instanceof ICDProjectStatementBean)) {

myBean = new ICDProjectStatementBean();

componentSession.putValue("myBean", myBean);

} else {

myBean = (ICDProjectStatementBean) o;

}

/***********End of Setting of the Bean object***************/

and in the JSP :-

<jsp:useBean id="myBean" scope="session" class="org.isdb.ICDPS.ICDProjectStatementBean" />

you have taken scope as request.

Try to do like the given code, hope this may help you.

Regards,

Deepak

Answers (9)

Answers (9)

former_member1279004
Participant
0 Kudos

Thank you all for the help.

Mike

srinivas_sistu
Active Contributor
0 Kudos

Hi Mike,

Add

myBean myBean = new myBean(); inside your JSP and then try....

more over,inside your bean class you can delete "implements serilizable" if you want so...

and in your portalapp.xml remove

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

entry.

so that your JSP looks like...

<%@ taglib uri="tagLib" prefix="hbj" %>

<%@ page import="com.sapportals.portal.prt.runtime.PortalRuntime" %>

<%@ page import="com.sapportals.portal.prt.resource.IResource" %>

<hbj:content id="myContext" >

<hbj:page title="PageTitle">

<hbj:form id="myFormId" >

//added here

<% myBean myBean = new myBean(); %>

//added till here

<%= myBean.getBappiReturn()%>

Regards,

Srinivas

Former Member
0 Kudos

Hi Mike,

As deepak said, in the jsp that you are using the code to get the value kept in the session keep the scope = "session"

Kind Regards,

Manoj Durairaj

former_member1279004
Participant
0 Kudos

Kumar,

Thank you for all the help, it is appreciated. Is it possible for you to send me the test application that is working for you. This way I can confirm whether there is an issue with my setup.

My e-address can be found in my profile.

Thank you.

Mike

Former Member
0 Kudos

Hi Mike,

This is at the remotest of conditions that one uses it. How about using the session property whose value will die with the age of the browser.

request.getServletRequest().getSession(true).setAttribute("<ABC>",value that you need to access in the jsp);

And in the use the code -- String test = (String)session.getAttribute("<ABC>");

Try this and this should for sure help you.

Kind Regards,

Manoj Durairaj

former_member1279004
Participant
0 Kudos

Kummar,

Thanks for the quick response. It did not work. I did award points for the quick response.

Mike

P.S> Does anyone have a working test application that you could send me to test.

Former Member
0 Kudos

Hi,

I worked out this and replied you. Your code working fine, you follow my previous post..

Regards,

Kumar

former_member1279004
Participant
0 Kudos

Kumar,

I did try it, but it did not help.

Thank you.

Mike

Former Member
0 Kudos

Hi,

Change the property <property name="PrivateSharingReference" value="com.sap.portal.htmlb,com.sap.portal.themes.lafservice,com.sap.portal.navigation.service,com.sap.portal.navigation.helperservice,com.sap.portal.pagebuilder,jco,jcoclient"/> in to <property name="SharingReference" value="com.sap.portal.htmlb, usermanagement, knowledgemanagement, landscape, htmlb, exportalJCOclient, exportal"/>

and remove this property in <component-config>

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

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

It will work.

Regards,

Kumar

former_member1279004
Participant
0 Kudos

Thanks Deepak and Harini for a quick response. I did try what you both suggested however it did not work.

Any thoughts.

Mike

P.S> I awarded points for your quick response

Former Member
0 Kudos

Hi,

Change public String bappiReturn = ""; to static String bappiReturn = ""; in your bean, i think it will help you...

Regards,

Kumar.

Former Member
0 Kudos

HI,

Create bean with application scope. Then this will work.

Also remove these lines from portalapp.xml

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

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

Regards,

Harini S