Hi Ketul, 

In a bean, the variables like setters and getters must follow a strict name 
convention. In the class Person, if you have a variable "name", then you must 
have a setter setName() and a getter getName(). In the class Name, you have 
variables firstName and lastName, then you must have setters setFirstName() and 
setLastName(). Note that the first character after "set" must be in upper case 
(i.e. "F" and "L"). Similarly, you must also have getters like getFirstName() 
and getLastName().

I hope this helps.

Regards,
Trung.


--- On Sat, 3/14/09, ketul <ketul....@gmail.com> wrote:

> From: ketul <ketul....@gmail.com>
> Subject: [java ee programming] Lab-4006:Help needed pls
> To: "Java EE (J2EE) Programming with Passion!" 
> <java-ee-j2ee-programming-with-passion@googlegroups.com>
> Date: Saturday, March 14, 2009, 6:38 AM
> * Can any one check what is wrong in my code
> 
> *I can see the page with "Hello" message and very
> small table BUT  NOT
> printing First Name and Last Name:
> ----------------------------------------------------------------------------------------------------------------------------------------
> *Response.java
> 
> <jsp:useBean id="mybean"
> scope="session"
> class="org.me.hello.NameHandler" />
>         <jsp:setProperty name="mybean"
> property="*"  />
>         Hello, <jsp:getProperty name="mybean"
> property="name" />
>         <br>
>         <br>
> 
>         <%-- Exercise Expression Language  --%>
>         <table border="1">
> 
>                 <tr>
>                     <td><c:out
> value="${person.name.firstName}"/></td>
>                     <td><c:out
> value="${person.name.lastName}"/></td>
>                </tr>
>         </table>
> 
> ------------------------------------------------------------------------------------------------------------------------------------------
> *InIt.java
> 
> 
> private void init(ServletContextEvent sce) {
> 
>             Person p1 = new Person("Ketul",
> "Patel");
> 
>            
> sce.getServletContext().setAttribute("per", p1);
>     }
> 
> -----------------------------------------------------------------------------------------------------------------------------------------------
> *Person.java
> 
> 
> public class Person {
> 
>    private Name name;
> 
>     public Person(String firstName, String lastName) {
>     name = new Name();
>     name.setfirstName(firstName);
>     name.setlastName(lastName);
>     }
> 
> }
> 
> -------------------------------------------------------------------------------------------------------------------------------------------------
> *Name.java
> 
> 
> public class Name {
> 
>     public String firstName;
>     public String lastName;
> 
>     public void setfirstName(String firstName){
>         this.firstName = firstName;
>     }
>     public void setlastName (String lastName){
>         this.lastName = lastName;
>     }
> 
>     public String getfirstName(){
>         return firstName;
>     }
> 
>     public String getlastName(){
>         return lastName;
>     }
> 
> 
> }
> 
> 

      

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Java 
EE (J2EE) Programming with Passion!" group.
To post to this group, send email to 
java-ee-j2ee-programming-with-passion@googlegroups.com
To unsubscribe from this group, send email to 
java-ee-j2ee-programming-with-passion+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/java-ee-j2ee-programming-with-passion?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to