Hi Chris,

thanks for your reply. I just wanted to share this exception with every one.
I kept getting error  "org.apache.taglibs.standard.examples.beans.Name does
not have a readable property firstname " while workgin on lab lab 4006_el*.
*
**
*    <td><c:out value="${person.name.firstname}"/></td>*

I had not declared class Name as public. It was a silly mistake but costed
me couple hours to figure out.


public class Name{
    private String firstname;
    private String lastname;

   Name(String fname, String lname){
    firstname = fname;
    lastname = lname;
    }
    public void setFirstname(String fname){
        this.firstname = fname;
    }

    public String getFirstname(){
        return firstname;
    }
    public String getLastname(){
        return lastname;
    }

    public void setLastname(String lname){
         this.lastname = lname;
    }
 }


Preet.
On Wed, May 26, 2010 at 11:09 AM, Chris K <ckella...@gmail.com> wrote:

> I had trouble with this one too, Michele was able to help me and I have
> copied her e-mail to me below:
>
> On Apr 19, 6:15 am, Chris K <ckella...@gmail.com> wrote:
> > I cannot get person.name.lastName or person.name.firstName to display
> > in the table.  I have combed the group and looked at many posts but
> > for the life of me I cannot tell what the problem is.
> >
> > I started by copying HelloWeb
> >
> > resides in package org.apache.taglibs.standard.
> examples.beans;
> > Person Class
> > public class Person {
> >     private Name name;
>
> This part below is rather strange for me:
> >     public Person(String firstName, String lastName) {
> >         Name name = new Name();
> >         name.setFirstname(firstName);
> >         name.setLastname(lastName);
> >     }
>
> I would have written as it is done in HelloWeb:
> public Person(Name name) {
>    init(name);
> }
>
> then
>
> public void init(Name name) {
>    setName(name);
> }
>
>
> >     public Name getName() {
> >         return name;
> >     }
> >     public void setName(Name name) {
> >         this.name = name;
> >     }
> >
>
> And incorporated here an overwritten version of the toString method
> exactly as done in the original HelloWeb.
>
> > }
> >
> > Name Class
> > public class Name {
> >     private String firstName;
> >     private String lastName;
> >     public Name() {
> >     }
> >     public Name(String firstName, String lastName) {
> >         this.firstName = firstName;
> >         this.lastName = lastName;
> >     }
>
> Here I would have used:
> public Name(String firstName, String lastName) {
>    setFirstName(firstName);
>    setLastName(lastName);
> }
> to ensure that the accessors methods are always used.
>
> >     public String getFirstname() {
> >         return firstName;
> >     }
> >     public void setFirstname(String firstName) {
> >         this.firstName = firstName;
> >     }
> >     public String getLastname() {
> >         return lastName;
> >     }
> >     public void setLastname(String lastName) {
> >         this.lastName = lastName;
> >     }
>
> Again an overwritten version of the toString method here.
> >
> > }
> >
> > Init
> > // Person
> >         Person p1 = new Person("Chris", "Kellawan");
> No, Person relies on Name to construct itself, so here:
> Person p1 = new Person(new Name("Chris", "Kellawan");
>
> >         sce.getServletContext().setAttribute("person", p1);
> >
> > response.jsp
> > <html>
> >     <head>
> >         <meta http-equiv="Content-Type" content="text/html;
> > charset=UTF-8">
> >         <title>JSP Page</title>
> >     </head>
> >     <body>
> >         <h1>response.jsp Page</h1>
> >         <jsp:useBean id="mybean" scope="application"
> > class="org.me.hello.NameHandler" />
> >         <jsp:setProperty name="mybean" property="*"  />
> >         Hello, <jsp:getProperty name="mybean" property="name" />
> >         <br>
> >         <br>
> Below you may simplify, (well if you have taken the  time to write an
> overriden version of the toString method), then you can get rid of the
> table, and use a p tag just using the name attribute of person, no
> need to getFirstName and getLastName. Unless you want to display a
> collection of Persons separating the first name from the last name, in
> which case you have also to write a Persons class, derived from the
> Customers class in HelloWeb project, but that is not asked in the
> homework.
> >         <%-- Exercise Expression Language  --%>
> >         <table border="1">
> >                 <tr>
> >                     <td><c:out value="${person.name.
> getFirstName}"/></
> > td>
> >                     <td><c:out value="${person.name.getLastName}"/></
> > td>
> >                </tr>
> >         </table>
> >     </body>
> > </html>
> >
> > Any help would be greatly appreciated.
> >
> > Thanks
> >
> > Chris Kellawan
> >
>
>
>   On Tue, May 25, 2010 at 6:14 PM, Preet K. Sekhon <pksek...@gmail.com>wrote:
>
>>   Hi everyone,
>>
>> I started the class late but I am trying to catch up. I have run into a
>> problem with lab 4006_el. I am not able to create Person object and
>> initialize it. I am defining my classes Person and Name under beans package.
>> When I try to initialize in Injit.java, I get an error message that the
>> Person class is not public and not accessible. I will appreciate any
>> suggestion to correct this
>> error.
>>
>> thanks,
>> Preet.
>>
>> --
>> 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<java-ee-j2ee-programming-with-passion%2bunsubscr...@googlegroups.com>
>> For more options, visit this group at
>>
>> http://groups.google.com/group/java-ee-j2ee-programming-with-passion?hl=en?hl=en
>
>
>
>
> --
> Chris Kellawan
> ckella...@gmail.com
>

-- 
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?hl=en

Reply via email to