Solved

Java beans

Posted on 2004-04-06
8
295 Views
Last Modified: 2010-04-01
I would like to ask how to compile simple java beans.

Do I need to install extra software, add extra info to the classpath?  Attempts to compile it give me error return type required and it points to the constructor of the bean.  

Can someone help?
0
Comment
Question by:11pm
  • 4
  • 3
8 Comments
 
LVL 92

Expert Comment

by:objects
ID: 10770605
no extra software required, you need to include any imported classes in the classpath.
What exactly is the error, and on what code is causing it?
0
 

Author Comment

by:11pm
ID: 10770974
This is the code.  Where can I compile beans.  I have a directory called servlet development from which I compile my servlets, but I can't do the same with beans.

Cheers
 

package business;

public class Customer{
      
    private String firstName;
    private String lastName;
    private String address;
    private String city;
    private String postCode;
    private String companyName;
    private String phoneNumber;
    private String faxNumber;
    private String emailAddress;
    private String creditCardType;
    private String creditCardNumber;
    private String creditCardExpirationDate;

    public Customer(){
          
        firstName = "";
        lastName = "";
        address = "";
        city = "";
        postCode = "";
        companyName = "";
        phoneNumber = "";
        faxNumber = "";
        emailAddress = "";
    }

    public User(String first, String last, String address, String city,
                String postCode, String companyName, String phoneNumber,
                String faxNumber, String email){
                      
        firstName = first;
        lastName = last;
        companyName = companyName;
        emailAddress = email;
        this.address = address;
        this.city = city;
        this.postCode = postCode;
        this.phoneNumber = phoneNumber;
        this.faxNumber = faxNumber;
    }

    public void setFirstName(String f){
        firstName = f;
    }
    public String getFirstName()
    { return firstName; }

    public void setLastName(String l){
        lastName = l;
    }
    public String getLastName()
    { return lastName; }
   
    public void setAddress(String a){
        address = a;
    }
    public String getAddress()
    { return address; }
   
    public void setCity(String c){
        city = c;
    }
    public String getCity()
    { return city; }
   
    public void setPostCode(String p){
        postCode = p;
    }
    public String getPostCode()
    { return postCode; }

    public void setCompanyName(String c){
        companyName = c;
    }
    public String getCompanyName()
    { return companyName; }
   
    public void setPhoneNumber(String pn){
        phoneNumber = pn;
    }
    public String getphoneNumber()
    { return phoneNumber; }
   
    public void setFaxNumber(String fn){
        faxNumber = fn;
    }
    public String getFaxNumber()
    { return faxNumber; }
   
      public void setEmailAddress(String e){
        email = e;
    }
    public String getEmailAddress()
    { return email; }

      public void setCreditCardType(String c){
        creditCardType = c;
    }
    public String getCreditCardType()
    { return creditCardType; }

    public void setCreditCardNumber(String n){
        creditCardNumber = n;
    }
    public String getCreditCardNumber()
    { return creditCardNumber; }

    public void setCreditCardExpirationDate(String s){
        creditCardExpirationDate = s;
    }
    public String getCreditCardExpirationDate()
    { return creditCardExpirationDate; }
}
0
 
LVL 92

Expert Comment

by:objects
ID: 10771037
> package business;

as your bean is in the business package it needs to be in a directory called business

>     public User(String first, String last, String address, String city,

that should be:

    public Customer(String first, String last, String address, String city,
0
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 5

Accepted Solution

by:
KarcOrigin earned 30 total points
ID: 10771062
Change
public User -> public void User

Moreover you have forgotten to diclare email variable

0
 

Author Comment

by:11pm
ID: 10771091
Thank you, it obviously worked : )
0
 
LVL 92

Expert Comment

by:objects
ID: 10771112
> it obviously worked

but was it what you intended :)
0
 

Author Comment

by:11pm
ID: 10822683
>Moreover you have forgotten to diclare email variable

Where exactly?

objects, I was too tired and didn't release that acctually you diserved to get these points.  Your answer made it work. Sorry.

I have been working on this  application already for couple of days in a row.  I created this bean, which compiles and is fine, but now I don't know how to connect it to my system.

What is a use keeping these info in the bean?  

I understand that I add the bean to the session and can retrieve the info at any point, is that true?
But how do i do it from jsp and from servlet?  Is it the same mechanism?
0
 

Author Comment

by:11pm
ID: 10822694
And, sorry, I am new here, what does PQA means next to my questions?
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
JSP Popup page 2 126
java.util.concurrent.locks in java 3 199
Multiple Images Upload [JSP Web-application] 3 40
doubleChar java challenge 7 119
In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
Giving access to ESXi shell console is always an issue for IT departments to other Teams, or Projects. We need to find a way so that teams can use ESXTOP for their POCs, or tests without giving them the access to ESXi host shell console with a root …
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

790 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question