• 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 );
%>

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

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

--------------------------------------------------------------------------------

type Exception report

message

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

exception

org.apache.jasper.JasperException: /ss/WebRoot/SaveName.jsp(5,1) The value for the useBean class attribute UserData is invalid.
      org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:39)
      org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:409)
 

Pleas Help

0
cakurien
Asked:
cakurien
1 Solution
 
avinthmCommented:
you will have to put UserData class in some package.
then try deploying it.
0
 
KuldeepchaturvediCommented:
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"/>
 to
<jsp:useBean id="user" class="yourpackagename.UserData" scope="session"/>
then try it

0
 
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="*"/>
</jsp:useBean>

check this & get back.
0
 
radarshCommented:
>> i dont think that having a package is must.

It certainly is a must. Atleast for tomcat.

________
radarsh
0
 
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???
0

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