Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

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

Posted on 2003-11-16
8
395 Views
Last Modified: 2010-04-01
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?
0
Comment
Question by:changcy77
  • 3
  • 3
  • 2
8 Comments
 
LVL 15

Assisted Solution

by:jimmack
jimmack earned 20 total points
ID: 9760172
I'm not 100% certain, but I think your page directives should be more like this:

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

Author Comment

by:changcy77
ID: 9760670
Thanks. One thing I don't understand is the same codes work fine on my own machine...only the Tomcat version is different.
0
 
LVL 14

Accepted Solution

by:
kennethxu earned 20 total points
ID: 9765052
>> One thing I don't understand is the same codes work fine on my own machine...only the Tomcat version is different.

The jsp specification didn't say that you can specify multiple import attribute in one page directive. so it is just that the newer version is more tolerant to your mistake.

both of below compliant to jsp spec:

<%@ page import="java.util.*, import="java.io.*, import="java.lang.Math" %>

-- or --

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

point should goes to jimmack
0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
LVL 15

Expert Comment

by:jimmack
ID: 9765285
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 ;-)
0
 

Author Comment

by:changcy77
ID: 9768778
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)
0
 
LVL 15

Expert Comment

by:jimmack
ID: 9769915
login.jsp shouldn't be in E:\  It should be in the webapps\polym directory along with your other JSPs.
0
 
LVL 14

Expert Comment

by:kennethxu
ID: 9772668
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.
0
 
LVL 14

Expert Comment

by:kennethxu
ID: 9772819
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?" )%>
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article describes how to reset your Windows 10 password when you've forgotten it.
Many businesses neglect disaster recovery and treat it as an after-thought. I can tell you first hand that data will be lost, hard drives die, servers will be hacked, and careless (or malicious) employees can ruin your data.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question