Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Calling java classes from jsp  RSS feed

 
RaviSingh Kumar
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi i am new with this tech. I am trying to call a java classes from a jsp page.
For that i had complied the java file under Web-INF -> classes folder.
But it is showing error "Class Not found Exception."

Can any one tell the steps to be followed for the above.
 
paritosh ranjan
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you give some more information like the part of code which is calling the class(method of the class most probably), and anything else which can help us find the problem.
 
RaviSingh Kumar
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In jsp page i am using this code.

<%@page language="java" %>

<jsp:useBean id="user" class="HelloBean" scope="session"/>

<html>
Hello
</html>
 
paritosh ranjan
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please try it once:
Keep your javabean in a package named mypackage.
TO be more specific
"WEB-INF/classes/mypackage/HelloBean.class"
and in your useBean give full classname like
<jsp:useBean id="user" class="mypackage.HelloBean" scope="session"/>

Just try this once,sometimes there is a problem if you don't keep your class in a package.I am not sure that this will work,but I faced a similar problem like this once and keeping it in a package helped.
 
RaviSingh Kumar
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Getting the same error even when a class is compile in to a package.
Please give some tips to get access to a class from a jsp page.
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What does the useBean look now, and where in the directory hierarchy is the class file? Have you reloaded the web app after re-deploying the class?
 
RaviSingh Kumar
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
class file directory webapps->Test->WEB-INF->classes folder.
Yes i had re-deploy after compiling the class.
 
Baseet Ahmed
Ranch Hand
Posts: 225
Java Notepad Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Originally posted by Ravi.
class file directory webapps->Test->WEB-INF->classes folder.


Tell your exact path of bean class file.

As mentioned by paritosh,put your class file in package format if its not.

Reload the application.

Then try again.


***********************************
Tip: Modesty is all virtue.
***********************************
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!