Logo 
Search:

Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

jsp, db AND beans

  Asked By: Clifford    Date: Sep 30    Category: Java    Views: 941
  

how does the bean know which variables r
his?<br><br>if i do <jsp:setProperty name= "teacher" property
= "*"/> <br>how does he know which r
his?<br><br>cos i have a method in bean which is setTeacher(int
code, string name, etc...)<br><br>how do i pass it to
the bean?? i dun get it, the book i have is so
totally vague!

Share: 

 

1 Answer Found

 
Answer #1    Answered By: Jared Adams     Answered On: Sep 30

The JSP set property tag will perform the set on
sets that have single parameters. The JSP
compiler uses something called "introspection" to look at
the Java bean  and find all the set<variable
name> methods. It then looks at the "request" object to
see if a variable with the same name  has been set in
the request object. If you have a parameter in
your previous page or you set it in the servlet that
is named like this: setParameter("teacher",
"Mrs. Grouch"); (I actually had a teacher named
that... she was really nice). You would have a
method in the Bean like
this. bean.setTeacher(String param); Notice that the first
character in
the parameter is not capitalized and the first
character of Teacher in the set method  is
capitalized. You can actually see the code generated by the tag if
you look up the java generated by the JSP
compile.... Also, check out the java.reflection.* API's... They
allow you to do alot of "dynamic" programming...
Hope this helps. Stephen
McConnell http://www.crosslogic.com

 
Didn't find what you were looking for? Find more on jsp, db AND beans Or get search suggestion and latest updates.




Tagged: