Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > How do I call my java method from JSP

Reply
Thread Tools

How do I call my java method from JSP

 
 
marcussilfver@gmail.com
Guest
Posts: n/a
 
      03-18-2008
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.
 
Reply With Quote
 
 
 
 
marcussilfver@gmail.com
Guest
Posts: n/a
 
      03-18-2008
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.

 
Reply With Quote
 
 
 
 
marcussilfver@gmail.com
Guest
Posts: n/a
 
      03-18-2008
On 18 Mar, 13:57, (E-Mail Removed) 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
 
Reply With Quote
 
northerntechie
Guest
Posts: n/a
 
      03-18-2008
On Mar 18, 11:34 am, (E-Mail Removed) wrote:
> On 18 Mar, 13:57, (E-Mail Removed) 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.
 
Reply With Quote
 
marcussilfver@gmail.com
Guest
Posts: n/a
 
      03-19-2008
On 18 Mar, 19:44, northerntechie <(E-Mail Removed)> wrote:
> On Mar 18, 11:34 am, (E-Mail Removed) wrote:
>
>
>
>
>
> > On 18 Mar, 13:57, (E-Mail Removed) 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.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
Poll: Is a Java Method an Instance of the Java Classjava.lang.reflect.Method? Please reply with YES or NO. Paka Small Java 15 02-07-2012 07:04 PM
JSP newbie - can I use JSP to access exiting java classes withoutre-write to javabeans terry433iid@yahoo.com Java 2 03-17-2008 01:40 AM
[JSP] difference between jsp:forward and jsp:include alexjaquet@gmail.com Java 0 06-02-2006 01:21 PM
How to get the html output of a local JSP page from my Java code, or use a JSP as an HTML templates. DigitalUncle Java 0 11-02-2004 05:22 PM



Advertisments