Javascript  
 
  ScriptJava  
 
  Perl  
 
  PHP  
 
  ROR  
 
  ask us  
 

 

Applications
  1. Getting started
  2. Definitions
  3. First program
  4. Characters and Strings
  5. Object and methods
  6. Arrays and Circles
  7. Exceptions
  8. The main method
  9. Reading
  10. Writing file
  11. Vectors
  12. Stacks
  13. Map The Dictionary
  14. Lists
  15. Linked lists
  16. Collection
  17. Interfaces
  18. Scanner
  19. StringTokenizer
  20. Generics
  21. JDBC
  22. DataBase Queries
  23. JSP, The main step

Graphics

Applets
  1. Regards
  2. One Picture
  3. Calculator
  4. Random pictures
  5. Bouncing picture

Swings
  1. Buttons listeners
  2. TextFields
  3. Swing Example

JavaBeans
  1. The first step
  2. Example

Search a word:
   



© The scientific sentence. 2010

Java beans and JSP Example Atoms
JavaBeans Example: Atoms.java, Atoms.jsp, Atoms.class, Atoms.html


 1. The steps 

1. Create new directory : newBeans under:
C:\Program Files\Apache Software Foundation\Tomcat 6.0\
webapps\examples\WEB-INF\classes\
directory. And then a new one under newBeans: 
newBeans\AtomBeans

2. Place the Java program Atoms in it :
C:\Program Files\Apache Software Foundation\Tomcat 6.0\
webapps\examples\WEB-INF\classes\newBeans\AtomBeans\Atoms.java
The Java program Atoms.java will have the following package:
package newBeans.AtomBeans; (subdirectories after \classes\)

3. Create a subdirectory (or subdirectories) under 
\webapps\ like this:
C:\Program Files\Apache Software Foundation\Tomcat 6.0\
webapps\examples\NewWork\BeansAtoms\
\examples\ already exist; NewWork\BeansAtoms\  is created. 

4. Place the JSP program Atoms.jsp in it as follows:
C:\Program Files\Apache Software Foundation\Tomcat 6.0\
webapps\examples\NewWork\BeansAtoms\Atoms.jsp

5. Rum the program Atoms.jsp by browsing:
http://localhost/examples/NewWork/BeansAtoms/Atoms.jsp



 2. The bean program Java:Atoms.java

package newBeans.AtomBeans;

public class Atoms implements java.io.Serializable {

private static final long serialVersionUID = 1L;

//Fields = properties
private String element = null;
private int charge = 0;
private int shell = 0;

// Constructor	
public Atoms() {}

// Methods: Setter
public void setelement(String element) {
this.element = element;
}

public void setcharge(int charge) {
this.charge = charge;
}

public void setshell(int shell) {
this.shell = shell;
}

// Method: Getter
public String getelement() {
return this.element;
}

public int getcharge() {
return this.charge;
}

public int getshell() {
return this.shell;
}

}


 3. Atoms.jsp 


<html>
<head>
<title> The atoms bean JSP Page</title>
</head>
<body>

<%@ page language="java" import="
newBeans.AtomBeans.Atoms"%> 
<%@ page contentType="text/html" %>


<%-- Create the JavaBean: of ID = Bohr --%>
<jsp:useBean id = "Bohr" scope="request"  class = 
"newBeans.AtomBeans.Atoms">
<jsp:setProperty name = "Bohr" property = 
"element" value = "Hydrogen" />
<jsp:setProperty name = "Bohr" property = 
"charge" value="1" />
<jsp:setProperty name = "Bohr" property = 
"shell" value="1" /> 
</jsp:useBean>

<p>
Retrieve the properties from JavaBean and display 
their values :<br>
The charge and the shell of the element 
<jsp:getProperty name="Bohr" property = "element"/> 
are respectively:
<jsp:getProperty name="Bohr" property = "charge"/> 
and 
<jsp:getProperty name="Bohr" property = "shell"/>. 
<br>

</p>
</body>
</html>


 4.The result 	

The result under: http://localhost/examples/NewWork/BeansAtoms/Atoms.jsp 
is:

Retrieve the properties from JavaBean and display their values :
The charge and the shell of the element Hydrogen are respectively: 1 and 1. 


  
Google
Web
ScientificSentence
 




chimie labs
|
scientific sentence
|
java
|
php
|
green cat
|
contact
|


© Scientificsentence 2009. All rights reserved.