Re: jsp and classpath
From: Dmytro Sheyko (dshe_at_isd.dp.ua)
Date: 04/16/04
- Next message: Andy Fish: "Re: is catch and re-throw a good idea?"
- Previous message: Franklin Lee: "Re: Help with java socket."
- In reply to: Yamin: "Re: jsp and classpath"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Fri, 16 Apr 2004 10:59:45 +0300
> > > I'm just started off learning a bit of jsp and jservlets. I got the
> basic
> > > setup to run. But I'm having a slight problem here.
> > >
> > > The SETUP:
> > > ***************************************
> > > G:\www\Tomcat 5.0\webapps\test\WEB-INF/classes
> > > crazyClass.java, crazyClass.class, crazyClass.jar
> > > G:\www\Tomcat 5.0\webapps\test\WEB-INF\lib
> > > catalina-root.jar
> > > ***************************************
> >
> > Move crazyClass.jar from WEB-INF/classes to WEB-INF/lib
> >
> > Web Server adds jars and zips from WEB-INF/lib into classpath of web
> > application. But not from WEB-INF/classes
> >
>
> Hey Dmytro,
>
> I tried that, and I get the same error message
> *********************************************************
> org.apache.jasper.JasperException: Unable to compile class for JSP
> An error occurred at line: 4 in the jsp file: /test.jsp
> Generated servlet error:
> [javac] Compiling 1 source file
>
> G:\www\Tomcat
> 5.0\work\Catalina\localhost\test\org\apache\jsp\test_jsp.java:52: cannot
> resolve symbol
> symbol : variable crazyClass
> location: class org.apache.jsp.test_jsp
> out.print( "at " + crazyClass.getValue() );
> ^
> 1 error
> *********************************************************
Hello Yamin,
I made a test and got the same error as you pointed.
As far as I understand, the JSP compiler treats crazyClass as a variable but
not as a class. The workaround is to put class into a package.
Consider slightly changed example:
**********************************************************************
WEB-INF\lib
crazyClass.jar
index.jsp
**********************************************************************
<!-- index.jsp -->
<%@page import="test.crazyClass"%>
<HTML>
<BODY>
<H1><%= "Test!" %></h1><%= "at " +
java.util.Calendar.getInstance().getTime() %>
<H2><%= " Line test" %></h2><%= "at " + crazyClass.getValue() %>
</BODY>
</HTML>
**********************************************************************
// test/crazyClass.java
package test;
import java.io.*;
import java.text.*;
import java.util.*;
public class crazyClass
{
public static int x = 0;
public static String getValue()
{
x++;
return Integer.toString(x);
}
}
**********************************************************************
- Next message: Andy Fish: "Re: is catch and re-throw a good idea?"
- Previous message: Franklin Lee: "Re: Help with java socket."
- In reply to: Yamin: "Re: jsp and classpath"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|