Results 1 to 2 of 2

Thread: How JSP call java function from class file

  1. #1
    Join Date
    May 2006
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Exclamation How JSP call java function from class file

    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

  2. #2
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    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).
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •