aspose file tools*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Bean? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Bean?" Watch "Bean?" New topic
Author

Bean?

pallavi utukuri
Ranch Hand

Joined: Feb 10, 2004
Posts: 182
hii
i have just started reading scriptless JSP's.....its all beginning with JavaBean....i am not familiar with Beans do i need to take a short crash course on Beans or can i go forward??? is Bean knowledge must to understand all other chapters?


Thanks,<br />Pallavi
parul sahu
Greenhorn

Joined: Sep 19, 2004
Posts: 3
Hi

Prerequisite for jsp is html and java.

The standard way of handling forms in JSP is to define a "bean". You just need to define a class that has a field corresponding to each field in the form. The class fields must have "setters" that match the names of the form fields.

Once you have defined the class, compile it and make sure it is available in the web-server's classpath. The server may also define special folders where you can place bean classes.

Now you can just add the jsp:useBean tag and the jsp:setProperty tag. The useBean tag will look for an instance of the your class in the session. If the instance is already there, it will update the old instance. Otherwise, it will create a new instance of class(the instance of the class is called a bean), and put it in the session. The setProperty tag will automatically collect the input data, match names against the bean method names, and place the data in the bean!

Perhaps with this prior information, you can first get going with other topics like tags, directives, and session before getting to beans.
[ September 21, 2004: Message edited by: parul sahu ]
pallavi utukuri
Ranch Hand

Joined: Feb 10, 2004
Posts: 182
i think i need to do the example given in the book.or else cant be clear

created Person class in
D:\Tomcat4.1\webapps\foo\WEB-INF\classes

package foo;
public abstract class Person{
private String name;
public void setName(String name){
this.name=name;
}
public String getName(){
return name;
}
}

created Employee in
D:\Tomcat4.1\webapps\foo\WEB-INF\classes

package foo;
public class Employee extends Person{
private int empID;
public void setEmpID(int EmpID){
this.empID=empID;
}
public int getEmpID(){
return empID;
}
}

this is not compiling saying cannot resolve symbol Person
where should i place it to make it compile
parul sahu
Greenhorn

Joined: Sep 19, 2004
Posts: 3
Originally posted by pallavi utukuri:
i think i need to do the example given in the book.or else cant be clear

created Person class in
D:\Tomcat4.1\webapps\foo\WEB-INF\classes

package foo;
public abstract class Person{
private String name;
public void setName(String name){
this.name=name;
}
public String getName(){
return name;
}
}

created Employee in
D:\Tomcat4.1\webapps\foo\WEB-INF\classes

package foo;
public class Employee extends Person{
private int empID;
public void setEmpID(int EmpID){
this.empID=empID;
}
public int getEmpID(){
return empID;
}
}

this is not compiling saying cannot resolve symbol Person
where should i place it to make it compile


I think that Person.class is not present in the foo folder while u try to compile Employee. Try compiling like this "javac -d . Person.java".
pallavi utukuri
Ranch Hand

Joined: Feb 10, 2004
Posts: 182
Person class is compiling fine....but error is with Employee class how do i compile it
pallavi utukuri
Ranch Hand

Joined: Feb 10, 2004
Posts: 182
compiled Person using
javac -d . Person.java it compiled fine but same prob when compiling Employee cannot resolve symbol Person
pallavi utukuri
Ranch Hand

Joined: Feb 10, 2004
Posts: 182
got it used
set classpath=%classpath%;D:\Tomcat4.1\webapps\foo\WEB-INF\classes
then
javac Employee.java

do i have to set the classpath everytime y so?
li chenli
Greenhorn

Joined: Jul 01, 2004
Posts: 6
i cannot see the package foo ??
[ September 28, 2004: Message edited by: li chenli ]
 
Consider Paul's rocket mass heater.
 
subject: Bean?