hi guys,
i have a problem in jsp.
my tomcat and java are running perfectly.
i can even run jsp/servlet pages.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional //EN>
<HTML>
<HEAD><CENTER><H2> Random Numbers </H2></CENTER></HEAD>
<BODY>
<UL>
<IL><%= RandomUtilities.randomInt(10) %></IL>
<IL><%= RandomUtilities.randomInt(10) %></IL>
</UL>
</BODY>
</HTML> {code}
in the above jsp page, i'm invoking a static method that is located in RandomUtilities.class file.
{code} public class RandomUtilities
{
public static int randomInt(int range)
{
return(1+((int) Math.random() * range));
}
public static void main(String[] args)
{
System.out.println(randomInt(5));
}
} {code}
it doesn't recognize "RandomUtilities class", i don't know which directory to store the java classes so that when i use it via jsp pages it doesn't have any problem.
hehe also to mention that i have set classpath and path to the directory where the RandomUtilities.class is located, and even i have stored this java class file in the current directory of jsp but still it doesn't recognize the class and gives me a unchallengeable JasperException.
{code} 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: Unable to compile class for JSP:
An error occurred at line: 6 in the jsp file: /jsp/RandomVI.jsp
RandomUtilities cannot be resolved
3: <HEAD><CENTER><H2> Random Numbers </H2></CENTER></HEAD>
4: <BODY>
5: <UL>
6: <IL><%= RandomUtilities.randomInt(10) %></IL>
7: <IL><%= RandomUtilities.randomInt(10) %></IL>
8: </UL>
9: </BODY>
An error occurred at line: 7 in the jsp file: /jsp/RandomVI.jsp
RandomUtilities cannot be resolved
4: <BODY>
5: <UL>
6: <IL><%= RandomUtilities.randomInt(10) %></IL>
7: <IL><%= RandomUtilities.randomInt(10) %></IL>
8: </UL>
9: </BODY>
10: </HTML>
Stacktrace:
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:92)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330)
org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:439)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:334)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:312)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:299)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:586)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:317)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
note The full stack trace of the root cause is available in the Apache Tomcat/6.0.20 logs.
Apache Tomcat/6.0.20 {code}
everything else is working fine.