JSP Introduction
Simple JSP(Example-1)
JSP Err.Pag.(Example-2)
JavaBeans in JSP
JavaBeans(Example-3)
JSP Custom Tags
CustomTag(Example-4)
Design Patterns
Design Patt.(Example-5)
Bookmark This Site
|
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
|
- Write a java file and name it as FindAuthor.java
- Write a jsp file and name it as GetAuthorName.jsp
- Write a html file and name it as WelcomePage.html
- 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
-
Now compile the FindAuthor.java. CLICK HERE to see how to compile
-
After the java programs are compiled successfully, you can close the command prompt.
- 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)
-
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’);
-
Close the SQL Query Analyzer
-
Goto Control Panel (Start -> Settings ->Control Pannel)
-
Click Administrative Tools (in XP, click Performance and Maintenance) and then click Data Sources (ODBC)
-
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
-
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 ...
|
|
|