Win a copy of The Journey To Enterprise Agility this week in the Agile and Other Processes forum! And see the welcome thread for 20% off.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

How to call java class from jsp file  RSS feed

 
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I am developing 1 web application for which I need to call some functions in .java file from .jsp file. I tried <%@page import="mypackage.myclass" %> but its saying ClassNotFound Exception.

Some details of application are:
I am using Weblogic 9.2.

I am deploying myjsp.jsp in \bea\weblogic92\samples\server\examples\build\mainWebApp\Trial\myjsp.jsp

.java file in

\bea\weblogic92\samples\server\examples\build\mainWebApp\Trial\mypackage

compiling this file as package (i.e. using javac -d ).
While compiling I am giving .class file to be generated in \bea\weblogic92\samples\server\examples\build\mainWebApp\WEB-INF\classes\mypackage\

Is this approch correct? as I am getting:

Error 500--Internal Server Error

java.lang.NoClassDefFoundError: mypackage/myclass

Please help me as soon as poosible.

Thanks.
 
Author and ninkuma
Marshal
Posts: 66783
168
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Neha Deshmukh wrote:I am developing 1 web application for which I need to call some functions in .java file from .jsp file.


If this is the case, then you are following poor practices that have been discredited for over 8 years now. There should never be any Java code in a modern JSP. None. Ever.

Your page controller should perform all operations before forwarding to a JSP, in which only the JSTL and EL should be used.
 
Bartender
Posts: 1844
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your location of classes appears to be correct.
Have you tried restarting the server?

Basically, your class file has to be under WEB-INF/classes in the correct package structure (which it appears to be)
Are your files getting deployed to the place where the server is running?

 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!