I am not able to access a java class from jsp

Posted on 2006-04-16
Last Modified: 2008-02-01
I am using myeclipseide i have file called UserData.class file residing at C:\Tomcat 5.0\webapps\test\ss\WebRoot\WEB-INF\classes  in my SaveName.jsp file
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
 <jsp:useBean id="user" class="UserData" scope="session"/>
<jsp:setProperty name="user" property="*"/>

   String name = request.getParameter( "username" );
   session.setAttribute( "theName",  name );
   String age = request.getParameter( "userage" );
   session.setAttribute( "theage",  age );

    <title>My JSP 'SaveName.jsp' starting page</title>
    <A HREF="NextPage.jsp">Continue</A>

but i the flg error
---HTTP Status 500 -


type Exception report


description The server encountered an internal error () that prevented it from fulfilling this request.


org.apache.jasper.JasperException: /ss/WebRoot/SaveName.jsp(5,1) The value for the useBean class attribute UserData is invalid.

Pleas Help

Question by:cakurien
    LVL 6

    Expert Comment

    you will have to put UserData class in some package.
    then try deploying it.
    LVL 19

    Expert Comment

    you can  not use beans in jsp if they are not packaged
    so try putting your class in some package recompile it & then change your jsp

    <jsp:useBean id="user" class="UserData" scope="session"/>
    <jsp:useBean id="user" class="yourpackagename.UserData" scope="session"/>
    then try it

    LVL 23

    Expert Comment

    i dont think that having a package is must.
    just check if the UserData.class file exits in ss\WebRoot\WEB-INF\classes
    and just try this

    <jsp:useBean id="user"  scope="session" class="UserData">
    <jsp:setProperty name="user" property="*"/>

    check this & get back.
    LVL 10

    Expert Comment

    >> i dont think that having a package is must.

    It certainly is a must. Atleast for tomcat.

    LVL 23

    Accepted Solution

    I think the UserData.class file is not inside any package so he can directly specify the class name as it resides directly in classes folder.

    cakurien try my above piece of code if you get any error get back.

    And Mr. RadarsH

    >>It certainly is a must. Atleast for tomcat.

    where you got this info from???

    Featured Post

    Free Trending Threat Insights Every Day

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Join & Write a Comment

    Suggested Solutions

    Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
    Local Continuous Replication is a cost effective and quick way of backing up Exchange server data. The following article describes the steps required to configure Local Continuous Replication. Also, the article tells you how to restore from a backup…
    To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
    Sending a Secure fax is easy with eFax Corporate ( First, Just open a new email message.  In the To field, type your recipient's fax number You can even send a secure international fax — just include t…

    755 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now