SET AS HOME PAGE

ADD TO FAVORITES / BOOKMARK THIS WEBSITE (More Details)

Introduction

Servlet

Jsp

Security

Enterprise Beans

Contact Us


Simple Example for using JavaBeans in JSP (Continue...)

 Introduction

JavaBeans component design conventions govern the properties of the class, and the public methods that give access to the properties.

A JavaBeans component property can be:

  • Read/write, read-only, or write-only.
  • It means it contains a single value, or indexed, i.e. it represents an array of values.
There is no requirement that a property be implemented by an instance variable; the property must simply be accessible using public methods that conform to certain conventions:

  • For each readable property, the bean must have a method of the form:
    PropertyClass getProperty () { ... }
  • For each writable property, the bean must have a method of the form:
    setProperty (PropertyClass pc) { ... }
In addition to the property methods, a JavaBeans component must define a constructor that takes no parameters.

CLICK HERE to download this complete example (zip file)


 Steps to deploy and run this JSP using JavaBean Project

  1. Write a java file and name it as FindAuthor.java
  2. Write a jsp file and name it as GetAuthorName.jsp
  3. Write a html file and name it as WelcomePage.html
  4. Set the path in the command prompt
    set path=.;C:\progra~1\java\j2sdk1.5.0\bin;C:\Sun\AppServer\bin;
    Set classpath=.;C:\progra~1\java\j2sdk1.5.0\lib;C:\Sun\AppServer\lib\j2ee.jar;
    (OR)
    Set the path in the system itself. CLICK HERE for details
  5. Now compile the FindAuthor.java. CLICK HERE to see how to compile
  6. After the java programs are compiled successfully, you can close the command prompt.
  7. Check whether the MSSQL Server is running. If the MSSQL Server is not running then you need to start the MSSQL Server first (CLICK HERE for details)
  8. Open the SQL Query Analyzer (CLICK HERE for details)
    Now type the following queries
    Create table Sample1(au_fname varchar(20), address varchar(20), city varchar(20), state varchar(20), zip varchar(20), au_id varchar(20));
    Insert into Sample1 values(‘Franklin’, ‘address’, ‘city’, ‘state’, ‘12345’, ‘1’);
  9. Close the SQL Query Analyzer
  10. Goto Control Panel (Start -> Settings ->Control Pannel)
  11. Click Administrative Tools (in XP, click Performance and Maintenance) and then click Data Sources (ODBC)
  12. Now

    Click the "Add" button


    Select “SQL Server” and click Finish


    Write “Sample1” in the Name textbox. Then in the Server textbox write “.”


    Now Select the option “With SQL Server authentication using a login ID and password entered by the user”. Then select “Connect to SQL Server to obtain default settings for the additional configuration options”
    Then in the Login ID write “sa” and then press Next button


    Select the Change the default database to and give your database name (Optional)
    Next click the Next button


    Click the Finish button


    Click Text Data Source button


    Press OK button


    Press OK button


    Press OK button

  13. Now goto Start -> Programs -> Sun Microsystems ->Application Server PE -> Start Default Server (wait till it start and then press any key). CLICK HERE to see how to Start the Server

 Click Next To Continue ...
<- PREVIOUSNEXT ->