Solved

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

Posted on 2003-11-16
8
389 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
 
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
JSP Popup page 2 95
maven webservice projet error 6 79
servlet init param and contect param 3 53
console vs log file 16 76
Are you unable to connect or configure Hotmail email account in Microsoft Outlook 2010, 2007? Or Outlook.com emails are not downloading to Outlook? Lets’ see the problem and resolve Outlook Connector error syncing folder hierarchy (0x8004102A).
A Short Story about the Best File Recovery Software – Acronis True Image 2017
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

762 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now