You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Stefan Wuschek <wu...@googlemail.com> on 2011/04/16 16:13:53 UTC

Bean returns null value while using its get method

 Hello,

i am using tomcat 6.0.32 in combination with the eclipse plattform (helios).
I tried to write a very simple bean just for getting familiar with it. It is
a simple form [form.jsp] that asks for mail adress and by clicking the send
button it calls a jsp [result.jsp] and initiates a session bean
[formpara.class].

The result.jsp prints : null null de.test.formpara . There is no message in
the Log nor do I see any problems. The Bean class can be resolved (found).

Anybody who knows how to fix or find the mistake i probably made ?



form.jsp - code:


<
jsp:useBean id=*"formpara"* class=*"de.test.formpara"* scope=*"session"*></
jsp:useBean>

<
jsp:setProperty property=*"*"* name=*"formpara"*></jsp:setProperty>

<%@
page language=*"java"* contentType=*"text/html; charset=ISO-8859-1"*

pageEncoding=*"ISO-8859-1"*%>

<!
DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "
http://www.w3.org/TR/html4/loose.dtd">

<
html>

<
head>

<
meta http-equiv=*"Content-Type"* content=*"text/html; charset=ISO-8859-1"*>

<
title>Insert title here</title>

</
head>

<
body>

<FORM METHOD=*POST* ACTION=*"result.jsp"*>

<input type=*"text"* name=*"mail"*>

<input type=*"submit"* name=*"command"* value=*"CMD"*>

</FORM>

</
body>

</
html>

result.jsp - code:

<
jsp:useBean id=*"formpara"* class=*"de.test.formpara"* scope=*"session"*></
jsp:useBean>

<%@
page language=*"java"* contentType=*"text/html; charset=ISO-8859-1"*

pageEncoding=*"ISO-8859-1"*%>

<!
DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "
http://www.w3.org/TR/html4/loose.dtd">

<
html>

<
head>

<
meta http-equiv=*"Content-Type"* content=*"text/html; charset=ISO-8859-1"*>

<
title>Insert title here</title>

</
head>

<
body>

<%= formpara.getMail() %>

<%= formpara.getCommand() %>

<%= formpara.getClass() %>

</
body>

</
html>

formpara.java - code:
*

package
*de.test;

*

public
**class* formpara {

String
mail;

String
command;

*public* *void* setMail( String value )

{

mail = value;

}

*public* *void* setCommand( String value )

{

command = value;

}

*public* String getMail() { *return* mail; }

*public* String getCommand() { *return* command; }

}

Re: Bean returns null value while using its get method

Posted by Stefan Wuschek <wu...@googlemail.com>.
Hello Mark,

That is it ! Thank you very much.

2011/4/16 <ma...@apache.org>

> Stefan Wuschek <wu...@googlemail.com> wrote:
>
> > Hello,
> >
> >i am using tomcat 6.0.32 in combination with the eclipse plattform
> >(helios).
> >I tried to write a very simple bean just for getting familiar with it.
> >It is
> >a simple form [form.jsp] that asks for mail adress and by clicking the
> >send
> >button it calls a jsp [result.jsp] and initiates a session bean
> >[formpara.class].
> >
> >The result.jsp prints : null null de.test.formpara . There is no
> >message in
> >the Log nor do I see any problems. The Bean class can be resolved
> >(found).
> >
> >Anybody who knows how to fix or find the mistake i probably made ?
> >
> >
> >
> >form.jsp - code:
> >
> >
> ><
> >jsp:useBean id=*"formpara"* class=*"de.test.formpara"*
> >scope=*"session"*></
> >jsp:useBean>
> >
> ><
> >jsp:setProperty property=*"*"* name=*"formpara"*></jsp:setProperty>
> >
> ><%@
> >page language=*"java"* contentType=*"text/html; charset=ISO-8859-1"*
> >
> >pageEncoding=*"ISO-8859-1"*%>
> >
> ><!
> >DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "
> >http://www.w3.org/TR/html4/loose.dtd">
> >
> ><
> >html>
> >
> ><
> >head>
> >
> ><
> >meta http-equiv=*"Content-Type"* content=*"text/html;
> >charset=ISO-8859-1"*>
> >
> ><
> >title>Insert title here</title>
> >
> ></
> >head>
> >
> ><
> >body>
> >
> ><FORM METHOD=*POST* ACTION=*"result.jsp"*>
> >
> ><input type=*"text"* name=*"mail"*>
> >
> ><input type=*"submit"* name=*"command"* value=*"CMD"*>
> >
> ></FORM>
> >
> ></
> >body>
> >
> ></
> >html>
> >
> >result.jsp - code:
> >
> ><
> >jsp:useBean id=*"formpara"* class=*"de.test.formpara"*
> >scope=*"session"*></
> >jsp:useBean>
> >
> ><%@
> >page language=*"java"* contentType=*"text/html; charset=ISO-8859-1"*
> >
> >pageEncoding=*"ISO-8859-1"*%>
> >
> ><!
> >DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "
> >http://www.w3.org/TR/html4/loose.dtd">
> >
> ><
> >html>
> >
> ><
> >head>
> >
> ><
> >meta http-equiv=*"Content-Type"* content=*"text/html;
> >charset=ISO-8859-1"*>
> >
> ><
> >title>Insert title here</title>
> >
> ></
> >head>
> >
> ><
> >body>
> >
> ><%= formpara.getMail() %>
> >
> ><%= formpara.getCommand() %>
> >
> ><%= formpara.getClass() %>
> >
> ></
> >body>
> >
> ></
> >html>
> >
> >formpara.java - code:
> >*
> >
> >package
> >*de.test;
> >
> >*
> >
> >public
> >**class* formpara {
> >
> >String
> >mail;
> >
> >String
> >command;
> >
> >*public* *void* setMail( String value )
> >
> >{
> >
> >mail = value;
> >
> >}
> >
> >*public* *void* setCommand( String value )
> >
> >{
> >
> >command = value;
> >
> >}
> >
> >*public* String getMail() { *return* mail; }
> >
> >*public* String getCommand() { *return* command; }
> >
> >}
>
> Shouldn't the useBean and setProperty be in result.jsp rather than
> form.jsp?
>
> Mark
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

Re: Bean returns null value while using its get method

Posted by ma...@apache.org.
Stefan Wuschek <wu...@googlemail.com> wrote:

> Hello,
>
>i am using tomcat 6.0.32 in combination with the eclipse plattform
>(helios).
>I tried to write a very simple bean just for getting familiar with it.
>It is
>a simple form [form.jsp] that asks for mail adress and by clicking the
>send
>button it calls a jsp [result.jsp] and initiates a session bean
>[formpara.class].
>
>The result.jsp prints : null null de.test.formpara . There is no
>message in
>the Log nor do I see any problems. The Bean class can be resolved
>(found).
>
>Anybody who knows how to fix or find the mistake i probably made ?
>
>
>
>form.jsp - code:
>
>
><
>jsp:useBean id=*"formpara"* class=*"de.test.formpara"*
>scope=*"session"*></
>jsp:useBean>
>
><
>jsp:setProperty property=*"*"* name=*"formpara"*></jsp:setProperty>
>
><%@
>page language=*"java"* contentType=*"text/html; charset=ISO-8859-1"*
>
>pageEncoding=*"ISO-8859-1"*%>
>
><!
>DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "
>http://www.w3.org/TR/html4/loose.dtd">
>
><
>html>
>
><
>head>
>
><
>meta http-equiv=*"Content-Type"* content=*"text/html;
>charset=ISO-8859-1"*>
>
><
>title>Insert title here</title>
>
></
>head>
>
><
>body>
>
><FORM METHOD=*POST* ACTION=*"result.jsp"*>
>
><input type=*"text"* name=*"mail"*>
>
><input type=*"submit"* name=*"command"* value=*"CMD"*>
>
></FORM>
>
></
>body>
>
></
>html>
>
>result.jsp - code:
>
><
>jsp:useBean id=*"formpara"* class=*"de.test.formpara"*
>scope=*"session"*></
>jsp:useBean>
>
><%@
>page language=*"java"* contentType=*"text/html; charset=ISO-8859-1"*
>
>pageEncoding=*"ISO-8859-1"*%>
>
><!
>DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "
>http://www.w3.org/TR/html4/loose.dtd">
>
><
>html>
>
><
>head>
>
><
>meta http-equiv=*"Content-Type"* content=*"text/html;
>charset=ISO-8859-1"*>
>
><
>title>Insert title here</title>
>
></
>head>
>
><
>body>
>
><%= formpara.getMail() %>
>
><%= formpara.getCommand() %>
>
><%= formpara.getClass() %>
>
></
>body>
>
></
>html>
>
>formpara.java - code:
>*
>
>package
>*de.test;
>
>*
>
>public
>**class* formpara {
>
>String
>mail;
>
>String
>command;
>
>*public* *void* setMail( String value )
>
>{
>
>mail = value;
>
>}
>
>*public* *void* setCommand( String value )
>
>{
>
>command = value;
>
>}
>
>*public* String getMail() { *return* mail; }
>
>*public* String getCommand() { *return* command; }
>
>}

Shouldn't the useBean and setProperty be in result.jsp rather than form.jsp?

Mark



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org