Link to home
Start Free TrialLog in
Avatar of changcy77
changcy77

asked on

how Tomcat needs package name in front of the class after import?

Dear experts,

I move my application from my machine to production server running tomcat3.1 and found some codes are not working any more.

I am getting this error:

org.apache.jasper.JasperException: Unable to compile class for JSPNote: sun.tools.javac.Main has been deprecated.
E:\apps\tomcat\work\localhost_8080%2Fpolym\_0002falign_0002dresult_00033_0002ejspalign_0002dresult3_jsp_0.java:89: Class Hashtable not found.
                      Hashtable ad = (Hashtable)request.getAttribute("disclist");


If I add package name in front of the Hashtable, it will work. So, why the import statement not working?

<%@ page
import="java.util.*"
import="java.io.*"
import="java.lang.Math"
errorPage="ExceptionHandler.jsp"
%>

Thanks. Is this a Tomcat 3 problem?
SOLUTION
Avatar of jimmack
jimmack

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of changcy77
changcy77

ASKER

Thanks. One thing I don't understand is the same codes work fine on my own machine...only the Tomcat version is different.
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Aha!  Thanks kennethxu.  I though it might be something like that, but I haven't used anything earlier than Tomcat 4, so it would only have been a guess if I had posted that ;-)

changcy77, split the points - 20 each - I might have provided a solution, but kennethxu actually explained it ;-)
sorry, both of your answer did not work...

for <%@ page import="java.util.*, import="java.io.*, import="java.lang.Math" %>
error messages are :
org.apache.jasper.JasperException: /login.jsp(4,0) Unterminated <%@ page tag
      at org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:94)
      at org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:428)
      at org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:170)
      at org.apache.jasper.compiler.

****************************************************
for <%@ page import="java.util.*"  %>
<%@ page import="java.io.*" %>

error message is

org.apache.jasper.compiler.ParseException: E:\login.jsp(5,4) Invalid directive
      at org.apache.jasper.compiler.Parser$Directive.accept(Parser.java:186)
      at org.apache.jasper.compiler.Parser.parse(Parser.java:1073)
      at org.apache.jasper.compiler.Parser.parse(Parser.java:1038)
      at org.apache.jasper.compiler.Parser.parse(Parser.java:1034)
      at org.apache.jasper.compiler.Compiler.compile(Compiler.java:182)
login.jsp shouldn't be in E:\  It should be in the webapps\polym directory along with your other JSPs.
my bad, didn't check exactly
>> <%@ page import="java.util.*, import="java.io.*, import="java.lang.Math" %>
this is incorrect and it should be:
<%@ page import="java.util.*, java.io.*, java.lang.Math" %>

if you still have problem, post your code and we'll fix it for you.
I have just tested on Tomcat 3.2 and 3.3 ( don't have 3.1 on hand) both import works!

<%@ page import="java.io.*" %>
<%@ page import="java.util.*" %>
<%=new Date() %><p>
<%=new IOException( "works?" )%>

-- or --

<%@ page import="java.io.*, java.util.*" %>
<%=new Date() %><p>
<%=new IOException( "works?" )%>