cancel
Showing results for 
Search instead for 
Did you mean: 

create a par with servlet, jsp and bean

Former Member
0 Kudos

I want create a easy par (Portal Application Project) witch do somethink in the servlet transfer data with a bean to the jsp.

If i call this site the .jsp crate a new instance of bean but don't find the bean of the servlet!

How can help me? I search more as two days for solution ;-((

See this:

-


(myservlet.java)

package com.firma.test

import com.firma.test.mybean

import ...

public class displayJSP extends PageProcessorComponent {

public DynPage getPage(){

return new siteDynPage();

}

public static class siteDynPage extends JSPDynPage{

public void doInitialization(){

}

public void doProcessAfterInput() throws PageException {

}

public void doProcessBeforeOutput() throws PageException {

mybean myBean = new mybean();

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

((IPortalComponentRequest)getRequest()).getNode().putValue("myBean", myBean);

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

myBean.setMyText("TEST_OUTPUT1");

// Ausgabe

this.setJspName("myjsp.jsp");

}

}

}

-


(myjsp.jsp)

<BR>

<jsp:useBean

id="myBean"

scope="application"

class="com.firma.test.mybean"

/>

VAL: <jsp:getProperty name="myBean" property="myText" />

<BR>

-


(mybean.java)

package com.firma.test

import ...

import java.io.Serializable;

public class mybean implements Serializable {

private String myText = "LEER!!!";

public String getMyText() {

return myText;

}

public void setMyText(String string) {

myText = string;

}

}

Accepted Solutions (1)

Accepted Solutions (1)

detlev_beutner
Active Contributor
0 Kudos

Hi Patrick,

first, welcome on SDN!

About your question: The most common problem is when you created your project via NWDS wizards and the wizard put two lines within the portalapp.xml, which are wrong. These are:

<property name="ComponentType" value="jspnative"/> <property name="JSP" value="...some JSP name ..."/>

Just delete them from your portalapp.xml.

Hope it helps

Detlev

PS: Please consider rewarding points for helpful answers on SDN. Thanks in advance!

Former Member
0 Kudos

Thanks Detlev,

the NWDS added realy these two lines i deleted, but the problem is the same as before (nearly).

And I added these lines 4testing:

- - - - - - - - - - - - - - - - - -

<BR>

GET: <jsp:getProperty name="myBean" property="myText" />

<BR>

SET: <jsp:setProperty name="myBean" property="myText" value="TESTING !!! JSP" />

<BR>

GET: <jsp:getProperty name="myBean" property="myText" />

<BR>

- - - - - - - - - - - - - - - - - -

1st. GET is empty, 2nd. GET is "TESTING !!! JSP".

I think the JSP creates a new bean, whats wrong with these line

- - - - - - - - - - - - - - - - - -

(portalapp.xml)

<component name="displayJSP">

<component-config>

<property name="ClassName" value="com.firma.test.displayJSP"/>

<property name="SecurityZone" value="com.firma.test/high_safety"/>

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

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

</component-config>

- - - - - - - - - - - - - - - - - -

If i delete the 2 lines in portalapp.xml i resolved a error of the Server.

Message was edited by: Patrick Schreck

detlev_beutner
Active Contributor
0 Kudos

Hi Patrick,

you put the bean into the ServletRequest, so changing the scope maybe to "request" could make it work.

Also check out http://help.sap.com/saphelp_nw04/helpdata/en/2e/c87f41849d030de10000000a1550b0/frameset.htm and around.

Hope it helps

Detlev

Former Member
0 Kudos

Thanks,

scope i changed every time in JSP and in the servlet i write:

request.getServletRequest().setAttribute("myBean", myBean);

request.getNode().putValue("myBean", myBean);

request.getServletRequest().setAttribute("myBean", myBean);

- - - - - - - - - - - - - - - - - -

portalapp.xml ??? There is all corectly??

If i delete the two lines i have an error.

detlev_beutner
Active Contributor
0 Kudos

Hi Patrick,

> If i delete the two lines i have an error

The two lines mentioned by me?!?! They must be deleted. Send your portalapp.xml.

Hope it helps

Detlev

Former Member
0 Kudos

See my first replay to you!

I become WITH the two lines only an error, if the path/file is not correctly set.

Message was edited by: Patrick Schreck

detlev_beutner
Active Contributor
0 Kudos

Patrick,

once again, the lines must be deleted. With

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

in it, calling the component means directly calling the JSP. Your JSPDynPage implementation does not get called in this case, so no bean can be created / stored wherever.

Hope it helps

Detlev

Former Member
0 Kudos

OK,

i deleted again, now i havent an error!!

I don't know why i have first time on delete the files an error of the Server?

THANKS A LOT!

Problem is SOLVED.

Former Member
0 Kudos

I wanna thanks you, Detlev,

your suggestion help me very much because I was in a bit bother!

thanks to Patrick for the post, also!

regards

Cristian

Answers (0)