How do I call my java method from JSP

Discussion in 'Java' started by marcussilfver@gmail.com, Mar 18, 2008.

  1. Guest

    I am trying to call a Java method from a JSP script.

    This is the Java code

    package my_package;
    import java.io.*;

    public class CountUsers
    {
    public CountUsers()
    {
    }

    public void logUsers(String fileName, String content)
    {
    //some code
    }
    }

    This is some of the JSP code:

    <%@ page import="my_package.CountUsers.*" %>
    <jsp:useBean id="countUsers" scope="session"
    class="my_package.CountUsers"/>

    RESULT:
    When loading the JSP page, I get an error saying: The value for the
    useBean class attribute marcus_packet.CountUsers is invalid.
    The error is at the useBean row shown above.

    Do I have to place my java class in some specific folder for the JSP
    to find it?
    I am using Tomcat 6 on the server by the way.
     
    , Mar 18, 2008
    #1
    1. Advertising

  2. Guest

    Sorry, I misstyped the package name in the error message, it should
    be:
    The value for the useBean class attribute my_package.CountUsers is
    invalid.


    > RESULT:
    > When loading the JSP page, I get an error saying: The value for the
    > useBean class attribute marcus_packet.CountUsers is invalid.
    > The error is at the useBean row shown above.
     
    , Mar 18, 2008
    #2
    1. Advertising

  3. Guest

    On 18 Mar, 13:57, wrote:
    > Sorry, I misstyped the package name in the error message, it should
    > be:
    > The value for the useBean class attribute my_package.CountUsers is
    > invalid.
    >
    >
    >
    > > RESULT:
    > > When loading the JSP page, I get an error saying: The value for the
    > > useBean class attribute marcus_packet.CountUsers is invalid.
    > > The error is at the useBean row shown above.- Dölj citerad text -

    >
    > - Visa citerad text -


    Really, no one knows the answer to this??
    Do I maybe need to pack my class into a jar, or is it ok to put the
    class file itself on the server for Tomcat to access?

    Regards
    Marcus
     
    , Mar 18, 2008
    #3
  4. On Mar 18, 11:34 am, wrote:
    > On 18 Mar, 13:57, wrote:
    >
    > > Sorry, I misstyped the package name in the error message, it should
    > > be:
    > > The value for the useBean class attribute my_package.CountUsers is
    > > invalid.

    >
    > > > RESULT:
    > > > When loading the JSP page, I get an error saying: The value for the
    > > > useBean class attribute marcus_packet.CountUsers is invalid.
    > > > The error is at the useBean row shown above.- Dölj citerad text -

    >
    > > - Visa citerad text -

    >
    > Really, no one knows the answer to this??
    > Do I maybe need to pack my class into a jar, or is it ok to put the
    > class file itself on the server for Tomcat to access?
    >
    > Regards
    > Marcus


    I have had similar problems and used a manual fix by putting the class
    file in the /WEB-INF/classes/<package_folder> directory.

    In this case, your <package_folder> will be my_package.

    Hope this helps.

    Todd Saharchuk, AScT.
     
    northerntechie, Mar 18, 2008
    #4
  5. Guest

    On 18 Mar, 19:44, northerntechie <> wrote:
    > On Mar 18, 11:34 am, wrote:
    >
    >
    >
    >
    >
    > > On 18 Mar, 13:57, wrote:

    >
    > > > Sorry, I misstyped the package name in the error message, it should
    > > > be:
    > > > The value for the useBean class attribute my_package.CountUsers is
    > > > invalid.

    >
    > > > > RESULT:
    > > > > When loading the JSP page, I get an error saying: The value for the
    > > > > useBean class attribute marcus_packet.CountUsers is invalid.
    > > > > The error is at the useBean row shown above.- Dölj citerad text -

    >
    > > > - Visa citerad text -

    >
    > > Really, no one knows the answer to this??
    > > Do I maybe need to pack my class into a jar, or is it ok to put the
    > > class file itself on the server for Tomcat to access?

    >
    > > Regards
    > > Marcus

    >
    > I have had similar problems and used a manual fix by putting the class
    > file in the /WEB-INF/classes/<package_folder> directory.
    >
    > In this case, your <package_folder> will be my_package.
    >
    > Hope this helps.
    >
    > Todd Saharchuk, AScT.- Dölj citerad text -
    >
    > - Visa citerad text -


    Thanks for replying.
    I have my class file in such a directory. I am still getting the error
    message though. Should I maybe make a jar of it and put there instead?
    Right now I have the class file itself put there.
     
    , Mar 19, 2008
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.

Share This Page