Think of the order of operation.

Client asks for test1.jsp. A bean (foo.myBean) is instantiated and held in
the session, there is no name request paramter so the name value of the bean
is not updated.
The client clicks on submit, this passes a name=xxx parameter to test2.jsp,
which access the bean created in test1.jsp, where the name was initialised
in the constructor,

Kevin Jones
DevelopMentor
www.develop.com

> -----Original Message-----
> From: A mailing list about Java Server Pages specification and reference
> [mailto:[EMAIL PROTECTED]]On Behalf Of S Kumaresan
> Sent: 29 January 2001 11:51
> To: [EMAIL PROTECTED]
> Subject: jsp-javabeans problem
>
>
> Dear friends,
>  I am working in JSP and using the JSWDK server (and also Tomcat
> 3.2).I have
> programmed a very simple jsp-java bean program and i could not find where
> the error is.
>  I am having test1.jsp, test2.jsp, and myBean.java files.
>
> the test1.jsp gets the name of the user and submits to test2.jsp
> (jsp:setProperty tag)
> the file test2.jsp displays the name of the user.(jsp:getProperty tag)
> But the problem is that the given name (for eg. kennedy) is not displayed
> and instead of that
> a helo is displayed which is given in the constructor.
>
> eg
> Hello ...You entered helo
>
> *************** coding starts ******************
>
> herewith I am sending codes.Pl mail what is the problem with this. I am in
> urgent.
>
> test1.jsp
> **********
> <jsp:useBean id="myb" class="foo.myBean" scope="session"/>
> <jsp:setProperty name="myb" property="name"/>
>
> <html>
> <head>
> <title> page1 </title>
> </head>
>
> <body bgcolor="#FFFFFF">
> <form method="post" action="test2.jsp">hello
> <input name="name" type="text"><br>
> <input type="submit" value="Go">
> </form>
> </body>
> </html>
>
> test2.jsp
> **********
> <jsp:useBean id="myb" class="foo.myBean" scope="session"/>
> <html>
> <head>
> <title> page 2 </title>
> </head>
>
> <body bgcolor="#FFFFFF">
> Hello ... You entered <jsp:getProperty name="myb" property="name"/>
> </body>
> </html>
>
> myBean.java
> ***************
> package foo;
>
> public class myBean
> {
> private String name;
>
> public void setName(String n) {
> this.name = n;
> }
> public String getName() {
> return name;
> }
> public myBean(){name="helo";}
> }
> ************************** coding over ******************
> I am expecting your earlier reply.... and any help is appreciated.
>
> yours
> kumaresan.s
> (PS: the same program worked perfectly some days back...)
>
> ==================================================================
> =========
> To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
> JSP-INTEREST".
> For digest: mailto [EMAIL PROTECTED] with body: "set
> JSP-INTEREST DIGEST".
> Some relevant FAQs on JSP/Servlets can be found at:
>
>  http://java.sun.com/products/jsp/faq.html
>  http://www.esperanto.org.nz/jsp/jspfaq.html
>  http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
>  http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets

Reply via email to