PDA

Visualizza la versione completa : [JAVA/JSP] Internal Error


samoa
01-12-2005, 02:35
Incontro questo tipo di errore in explorer richiamando
test.jsp: (altri file gi funzionano con il web server)

errore:

type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.

test.jsp :

<%@ page session="false" %>
<%@ page import="java.sql.*, java.util.* %>
<html>
<head>
<title>Titolo</title>
</head>
<body>
<%
string Driver = "sun.jdbc.odbc.JdbcOdbcDriver";
Class.forName(Driver);
// database nella stessa cartella di pagina test.jsp
string URL = "dba.mdb";
string strcon = "jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ="+URL;

connection con = null;
con=DriverManager.getConnection(strcon, "", "");

string sql = "SELECT ragione_sociale, indirizzo FROM Clienti";
Statement stmt =con.createStatement();
ResultSet rs = stmt.executeQuery(sql);
%>

Titolo della tabella


<table width="50%" border="10">
<tr>
<th>Ragione_sociale</th>
<th>Indirizzo</th>
</tr>
<%
while (rs.next()) {
String ragione_sociale = rs.getString(1);
String indirizzo = rs.getString(2);
%>
<tr>
<td><%= ragione_sociale%></td>
<td><%= indirizzo%></td>
</tr>
<%
}
rs.close;
rs=null;

stmt.close();
stmt=null;

con.close();
%>
</table>
</body>
</html>





Cosa sbaglio?

V1RuZ
01-12-2005, 07:27
mancano le virgolette
<%@ page import="java.sql.*, java.util.*" %>

samoa
02-12-2005, 00:19
Serve attivare odbc in windows XP per una connessione ad access?

Continuo a non capire,

l'errore :


HTTP Status 500 -

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException: Unable to compile class for JSP

An error occurred at line: 11 in the jsp file: /example/lettura3.jsp
Generated servlet error:
Syntax error on tokens, delete these tokens

An error occurred at line: 43 in the jsp file: /example/lettura3.jsp
Generated servlet error:
Syntax error, insert "AssignmentOperator ArrayInitializer" to complete Expression


org.apache.jasper.compiler.DefaultErrorHandler.jav acError(DefaultErrorHandler.java:84)
org.apache.jasper.compiler.ErrorDispatcher.javacEr ror(ErrorDispatcher.java:328)
org.apache.jasper.compiler.JDTCompiler.generateCla ss(JDTCompiler.java:409)
org.apache.jasper.compiler.Compiler.compile(Compil er.java:288)
org.apache.jasper.compiler.Compiler.compile(Compil er.java:267)
org.apache.jasper.compiler.Compiler.compile(Compil er.java:255)
org.apache.jasper.JspCompilationContext.compile(Js pCompilationContext.java:563)
org.apache.jasper.servlet.JspServletWrapper.servic e(JspServletWrapper.java:293)
org.apache.jasper.servlet.JspServlet.serviceJspFil e(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspSe rvlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet .java:802)

note The full stack trace of the root cause is available in the Apache Tomcat/5.5.12 logs.

____________________


il codice :




<%@ page language="java" %>
<%@ page session="false" %>
<%@ page import="java.sql.*" %>
<%@ page import="java.util.*" %>
<html>
<head>
<title>La palestra di JSP</title>
</head>

<body>
<%

try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

String URL = "/dba.mdb";
String strcon = "jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ="+URL;

Connection con = null;
con=DriverManager.getConnection(strcon, "", "");

String sql = "SELECT ragione_sociale, indirizzo FROM Clienti";
Statement stmt =con.createStatement();
ResultSet rs = stmt.executeQuery(sql);*/
%>

Titolo della tabella


<table width="50%" border="10">
<tr>
<th>Ragione_sociale 1</th>
<th>Indirizzo 1</th>
</tr>
<%
while (rs.next()) {
String ragione_sociale = rs.getString(1);
String indirizzo = rs.getString(2);

%>
<tr>
<td><%=ragione_sociale%></td>
<td><%=indirizzo%></td>
</tr>
<%
}
rs.close;
rs=null;

stmt.close();
stmt=null;
}
catch(Exception e)
{
System.out.println("Error in creating the connection"+e);

}
%>
</table>
</body>
</html>

V1RuZ
02-12-2005, 01:06
<%@ page language="java" %>
<%@ page session="false" %>
<%@ page import="java.sql.*" %>
<%@ page import="java.util.*" %>
<html>
<head>
<title>La palestra di JSP</title>
</head>

<body>
<%

try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

String URL = "/dba.mdb";
String strcon = "jdbc:odbcriver={Microsoft Access Driver (*.mdb)};DBQ="+URL;

Connection con = null;
con=DriverManager.getConnection(strcon, "", "");

String sql = "SELECT ragione_sociale, indirizzo FROM Clienti";
Statement stmt =con.createStatement();
ResultSet rs = stmt.executeQuery(sql);
%>

Titolo della tabella


<table width="50%" border="10">
<tr>
<th>Ragione_sociale 1</th>
<th>Indirizzo 1</th>
</tr>
<%
while (rs.next()) {
String ragione_sociale = rs.getString(1);
String indirizzo = rs.getString(2);

%>
<tr>
<td><%=ragione_sociale%></td>
<td><%=indirizzo%></td>
</tr>
<%
}
rs.close();
rs=null;

stmt.close();
stmt=null;
}
catch(Exception e)
{
System.out.println("Error in creating the connection"+e);

}
%>
</table>
</body>
</html>


c'era un */ di troppo e rs.close lo puoi fare in vbscript ma in java devi fare rs.close();

samoa
02-12-2005, 09:10
grazie ora funge

Loading