How do I call my java method from JSP

M

marcussilfver

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.
 
M

marcussilfver

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.
 
M

marcussilfver

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.




- 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
 
N

northerntechie

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.
 
M

marcussilfver

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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,521
Members
44,995
Latest member
PinupduzSap

Latest Threads

Top