Ciao a tutti, sto facendo alcune prove con JSP e al momento della compilazione con netbeans mi ritorna il seguente errore:
----------------------------------------------
HTTP Status 500 -
type Exception report
message
descriptionThe server encountered an internal error () that prevented it from fulfilling this request.
exception
java.lang.IllegalStateException
note The full stack traces of the exception and its root causes are available in the GlassFish Server Open Source Edition 3.0.1 logs.
-----------------------------------------------------------------------
posto anche parte dello stack tracerts di glassfish:
AVVERTENZA: StandardWrapperValve[jsp]: PWC1406: Servlet.service() for servlet jsp threw exception
java.lang.IllegalStateException
at org.apache.catalina.connector.ResponseFacade.sendR edirect(ResponseFacade.java:522)
at org.apache.jsp.prodotti_jsp._jspService(prodotti_j sp.java]:308)
Questa è la pagina JSP prodotti:
<%@ page import="java.util.Date" %>
<%@ page import="java.util.Locale" %>
<%@ page import="java.text.NumberFormat" %>
<%@ include file="sql.jsp" %>
<html>
<%@ include file="heading.jsp" %>
<body>
<table width="100%" border="0">
<tr>
<td colspan="2" class="blubg">
<%@ include file="banner.jsp" %>
</td>
</tr>
<tr>
<td width="10%" class="blubg" valign="top">
<%@ include file="menu.jsp" %>
</td>
<td align="center" width="90%">
<%
try {
Connection c = DriverManager.getConnection(stringaConnessione, utenteSQL, passwordSQL);
Statement s = c.createStatement();
ResultSet r = s.executeQuery("SELECT * FROM prodotti");
ResultSetMetaData md = r.getMetaData();
%>
<div class="intestazione"></div>
<div class="intestazione">Catalogo dei prodotti disponibili:</div>
<div class="intestazione"></div>
<table border="0" cellpadding="5">
<tr>
<td class="intestazione_tabella">
Prodotto
</td>
<td class="intestazione_tabella">
Descrizione
</td>
<td class="intestazione_tabella">
Prezzo (&euro
</td>
<td class="intestazione_tabella">
Q.tà a magazzino
</td>
<td class="intestazione_tabella">
Q.tà da ordinare
</td>
<td class="intestazione_tabella">
Inserisci nel carrello
</td>
</tr>
<%
int riga=0;
while(r.next()) {
riga++;
%>
<tr>
<form method="post" action="inserisci.jsp">
<%
NumberFormat fmt=NumberFormat.getInstance(Locale.ITALIAN);
fmt.setMinimumFractionDigits(2);
fmt.setMaximumFractionDigits(2);
int indicePrezzo=4;
int indiceQt=5;
// L'indice i parte da 2 per evitare di visualizzare l'ID numerico del prodotto.
for (int i = 2; i <= md.getColumnCount(); i++) {
%>
<td class='<%= riga%2==0 ? "riga2_tabella" : "riga1_tabella"%>'>
<% if(i==indicePrezzo)
out.print(fmt.format(r.getFloat(i)));
else if(i==indiceQt)
out.print(r.getInt(i));
else
out.print(r.getString(i));
%>
</td>
<%
}
%>
<td class='<%= riga%2==0 ? "riga2_tabella" : "riga1_tabella"%>'>
<input type="text" name="qt" value="1" size="2">
</td>
<td class='<%= riga%2==0 ? "riga2_tabella" : "riga1_tabella"%>'>
<input type="submit" name="ordina" value=">>">
<input type="hidden" name="pid" value="<%= r.getInt(1)%>">
</td>
</form>
</tr>
<%
}
%>
</table>
<%
r.close(); s.close(); c.close();
} catch (SQLException e) {
response.sendRedirect("errore.jsp");
}
%>
</td>
</tr>
<tr>
<td colspan="2">
<%@ include file="footer.jsp" %>
</td>
</tr>
</table>
</body>
</html>
e questa è la pagina JSP sql.jsp che viene inclusa nella pagina prodotti
<%@ page language="java" import="java.sql.*" %>
<%!
String stringaConnessione="jdbc:mysql://local/MyShop";
String utenteSQL="root";
String passwordSQL="pippo";
int lunghezzaMassima=100;
double contributoSpeseSpedizione=30.0;
String CodificaApici(String s) {
String codifica="";
for(int i=0; i<s.length(); i++)
if(s.charAt(i)=='\'')
codifica+="''";
else
codifica+=s.charAt(i);
return codifica;
}
%>
<%
try {
Class.forName("com.mysql.jdbc.Driver");
} catch (ClassNotFoundException e) {
response.sendRedirect("errore.jsp");
}
%>
Qualcuno ha qualche idea?
Via ringrazio di cuore. Bye.