PDA

View Full Version : How JSP call java function from class file



melvinoyh
05-26-2006, 06:45 AM
hi guys, i wanna know how JSP call and pass parameter to a java function from class file.


class file
-----------------------------------------
public double calcQty(double pPect, double tQty)
{
return (pPect * tQty / 100);
}
------------------------------------------

JSP file
-------------------------------------------
<jsp:useBean id = "pc" class="common.claim" scope="request" />
the following code is call the function from the class file
<%=pc.calcQty()%>

izzit correct or not?
if let say i wan to call the function at onClick, how to write the code?
if i wanna pass in parameter to that function, how to write?
plz someone help. thx

Twey
05-26-2006, 11:46 AM
That's correct, yes.

But this makes a nice difference... usually people confuse Java and Javascript from the other direction :)
Java is not Javascript. Java has nothing whatsoever to do with Javascript; Javascript is a totally different language. It can interact with applets, but not servlets (save by use of AJAX).