Solved

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

Posted on 2003-11-16
8
397 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
[X]
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
  • 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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

Multi-threading long-running processes can have a significant increase in overall performance and drastically decrease over time it takes for a process to complete. Unfortunately, not all applications support native multi-threading, some by design a…
Sometimes clients can lose connectivity with the Lotus Notes Domino Server, but there's not always an obvious answer as to why it happens.   Read this article to follow one of the first experiences I had with Lotus Notes on a client's machine, my…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

688 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