?
Solved

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

Posted on 2003-11-16
8
Medium Priority
?
399 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 80 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 80 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
Independent Software Vendors: 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

Enroll in August's Course of the Month

August's CompTIA IT Fundamentals course includes 19 hours of basic computer principle modules and prepares you for the certification exam. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

This is a fine trick which I've found useful many times, when you just don't want to accidentally run a batch script or the commands needs administrator rights.
The Summer 2017 Scholarship Winners have been announced!
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Suggested Courses

770 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