• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 321
  • Last Modified:

I am not able to access a java class from jsp

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

1 Solution
you will have to put UserData class in some package.
then try deploying it.
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

Siva Prasanna KumarPrincipal Solutions ArchitectCommented:
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.
>> i dont think that having a package is must.

It certainly is a must. Atleast for tomcat.

Siva Prasanna KumarPrincipal Solutions ArchitectCommented:
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

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now