Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / March 2008

Tip: Looking for answers? Try searching our database.

How do I call my java method from JSP

Thread view: 
marcussilfver@gmail.com - 18 Mar 2008 13:53 GMT
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.
marcussilfver@gmail.com - 18 Mar 2008 13:57 GMT
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.
marcussilfver@gmail.com - 18 Mar 2008 19:34 GMT
On 18 Mar, 13:57, marcussilf...@gmail.com wrote:
> Sorry, I misstyped the package name in the error message, it should
> be:
[quoted text clipped - 7 lines]
>
> - 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
northerntechie - 18 Mar 2008 19:44 GMT
On Mar 18, 11:34 am, marcussilf...@gmail.com wrote:
> On 18 Mar, 13:57, marcussilf...@gmail.com wrote:
>
[quoted text clipped - 16 lines]
> 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.
marcussilfver@gmail.com - 19 Mar 2008 09:02 GMT
> On Mar 18, 11:34 am, marcussilf...@gmail.com wrote:
>
[quoted text clipped - 29 lines]
>
> - 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.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.