6 messages in com.mysql.lists.javaRE: JSP Date Class' conflict ( a bi...
FromSent OnAttachments
Mich...@i2.com20 Sep 2001 10:48 
Igor Fedulov20 Sep 2001 11:03 
Robert Casto20 Sep 2001 11:04 
Tim Endres20 Sep 2001 11:10 
Dirk Hillbrecht20 Sep 2001 11:11 
O'Hara, Patrick20 Sep 2001 11:16 
Subject:RE: JSP Date Class' conflict ( a bit long - code and errors )
From:Robert Casto (rob@cincijava.com)
Date:09/20/2001 11:04:16 AM
List:com.mysql.lists.java

The problem is typical of programs that import java.util.* and java.sql.* which both contain the Date class. In fact the Date class in java.sql.* is a subclass of the one in java.util.*. Everywhere you are using the word Date you will have to change it to java.util.Date or java.sql.Date. In my code I always use the full package names to reference the class I am interested in. Sometimes though you can avoid the java.util.Date and use the java.sql.Date exclusively.

From what I can see in your code, just put java.util. in front of all Date class references and your problem should go away.

-----Original Message----- From: Mich@i2.com [mailto:Mich@i2.com] Sent: Thursday, September 20, 2001 1:48 PM To: ja@lists.mysql.com Subject: JSP Date Class' conflict ( a bit long - code and errors )

Hi All,

the JSP code works just fine, does a bunch of date calculations and sets up vars for later display in the HTML, except when

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

Date Today = new Date();

long goSec = Today.getTime(); String goStr = request.getParameter("goSec");

long fbSec = 0; long pbSec = 0; long faSec = goSec + 86400000; // 86400000 = 24 * 60 * 60 * 1000 long paSec = goSec - 86400000;

if (goStr == null) { fbSec = goSec + 172800000; // 172800000 = 2 * 86400000 pbSec = goSec - 172800000; } else { goSec = Long.parseLong(goStr);

fbSec = goSec + 86400000; pbSec = goSec - 86400000; }

Date goDay = new Date(goSec);

int goYY = goDay.getYear()+1900; int goMM = goDay.getMonth()+1; int goDD = goDay.getDate();

goStr = goMM < 10 ? "0" : ""; goStr += String.valueOf(goMM) + "-"; goStr += goDD < 10 ? "0" : ""; goStr += String.valueOf(goDD) + "-" + String.valueOf(goYY);

%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<html> <head> ...

I add the java.sql.* lib

<%@page language="java" import="java.util.*, java.lang.*, java.sql.*" %>

then the JSP container spills out

500 Internal Server Error

/gapCard-BAK.jsp:

javax.servlet.ServletException: Compilation error occured: Found 4 errors in JSP file:

C:\\Program Files\\Allaire\\JRun\\servers\\default\\default-app\\gapCard-BAK.jsp:10: Error: Type Date is imported on demand from package java/util and package java/sql.

C:\\Program Files\\Allaire\\JRun\\servers\\default\\default-app\\gapCard-BAK.jsp:10: Error: Type Date is imported on demand from package java/util and package java/sql.

C:\\Program Files\\Allaire\\JRun\\servers\\default\\default-app\\gapCard-BAK.jsp:32: Error: Type Date is imported on demand from package java/util and package java/sql.

C:\\Program Files\\Allaire\\JRun\\servers\\default\\default-app\\gapCard-BAK.jsp:32: Error: Type Date is imported on demand from package java/util and package java/sql.

allaire.jrun.scripting.DefaultCFE: Errors reported by compiler: C:/Program Files/Allaire/JRun/servers/default/default-app/WEB-INF/jsp/jrun__gapCard2dBA K2ejsp10.java: 45:1:45:4: Error: Type Date is imported on demand from package java/util and package java/sql.

C:/Program Files/Allaire/JRun/servers/default/default-app/WEB-INF/jsp/jrun__gapCard2dBA K2ejsp10.java: 45:18:45:21: Error: Type Date is imported on demand from package java/util and package java/sql.

C:/Program Files/Allaire/JRun/servers/default/default-app/WEB-INF/jsp/jrun__gapCard2dBA K2ejsp10.java: 67:1:67:4: Error: Type Date is imported on demand from package java/util and package java/sql.

C:/Program Files/Allaire/JRun/servers/default/default-app/WEB-INF/jsp/jrun__gapCard2dBA K2ejsp10.java: 67:18:67:21: Error: Type Date is imported on demand from package java/util and package java/sql.

at allaire.jrun.scripting.JavaCompilerService.compile(JavaCompilerService.java: 122) at allaire.jrun.jsp.JSPServlet.compilePage(JSPServlet.java:452) at allaire.jrun.jsp.JSPServlet.createServlet(JSPServlet.java:393) at allaire.jrun.jsp.JSPServlet.loadPage(JSPServlet.java:201) at allaire.jrun.jsp.JSPServlet.service(JSPServlet.java:168) at allaire.jrun.servlet.JRunSE.service(JRunSE.java:1013) at allaire.jrun.servlet.JRunSE.runServlet(JRunSE.java:925) at allaire.jrun.servlet.JRunRequestDispatcher.forward(JRunRequestDispatcher.jav a:88) at allaire.jrun.servlet.JRunSE.service(JRunSE.java:1131) at allaire.jrun.servlet.JvmContext.dispatch(JvmContext.java:330) at allaire.jrun.http.WebEndpoint.run(WebEndpoint.java:107) at allaire.jrun.ThreadPool.run(ThreadPool.java:267) at allaire.jrun.WorkerThread.run(WorkerThread.java:74)

QUESTION: How do I resolve the Date Class conflict or are there method calls within the java.sql.* lib that cab do the equilelent?

To unsubscribe, send a message to the address shown in the List-Unsubscribe header of this message. If you cannot see it, e-mail java@lists.mysql.com instead.