Ver Mensaje Individual
  #3 (permalink)  
Antiguo 03/01/2007, 08:43
Langas
 
Fecha de Ingreso: enero-2007
Mensajes: 17
Antigüedad: 17 años, 4 meses
Puntos: 0
Re: IllegalStateException en JSP

Gracias por responder tan rápidamente, Greeneyed.

Si te he entendido bien, la fuente del conflicto entre getOutputStream() y getWriter() radica en la propia inclusión de HTML en el código JSP. Luego debería funcionar si suprimo el HTML en dicho código. Por desgracia, acabo de intentar una solución borrando todas las etiquetas HTML y sigue lanzando la misma excepción. El código fuente (completo) ahora es:

<%@ page contentType="text/html; charset=iso-8859-1" language="java" import="java.sql.*" import="java.io.*"%>
<%@ include file="/Connections/conexion.jsp" %>
<%@ taglib uri="/WEB-INF/lib/taglibDescarga.tld" prefix="do" %>

<%--Inicialización de variables--%>
<%
String fechaInforme = "";
String extInforme = "";
String ccInforme = "";
String tipoInforme = "";
String tempInforme = "Fecha\tCentro de Coste\tExtensión\tTipo de Llamada\tNum. Llamadas\tTotal segundos\tImporte Total(\u20AC)\n";
if (request.getParameter("reqFecha") != null){
fechaInforme = request.getParameter("reqFecha");
} else fechaInforme = "%";
if (request.getParameter("reqExt") != null){
extInforme = request.getParameter("reqExt");
} else extInforme = "%";
if (request.getParameter("reqCentroCoste") != null){
ccInforme = request.getParameter("reqCentroCoste");
} else ccInforme = "%";
if (request.getParameter("reqTipo") != null){
tipoInforme = request.getParameter("reqTipo");
} else tipoInforme = "%";
String ano = "";
String mes = "";
String dia = "";
String nombreInforme = "informeAgregadoTPI" + fechaInforme + extInforme + ccInforme + tipoInforme;
int acumNumeroLlamadas = 0;
int acumTotalSegundos = 0;
double acumImporte = 0;
%>

<%--Creación de juego de registros de agregado--%>
<%
Driver DriverRegistros = (Driver)Class.forName(MM_conexion_DRIVER).newInsta nce();
Connection ConnRegistros = DriverManager.getConnection(MM_conexion_STRING,MM_ conexion_USERNAME,MM_conexion_PASSWORD);
PreparedStatement StatementRegistros = ConnRegistros.prepareStatement("SELECT * FROM tarific.adt_agdiallama WHERE id_centro_coste LIKE ? AND nc_extension LIKE ? AND de_clase_llama LIKE ? AND co_dia LIKE ? GROUP BY co_dia, id_centro_coste, nc_extension, de_clase_llama ASC");
StatementRegistros.setString (1,ccInforme);
StatementRegistros.setString (2,extInforme);
StatementRegistros.setString (3,tipoInforme);
StatementRegistros.setString (4,fechaInforme + "__");
ResultSet Registros = StatementRegistros.executeQuery();
boolean Registros_isEmpty = !Registros.next();
boolean Registros_hasData = !Registros_isEmpty;
%>

<%--Bucle de escritura de registros--%>
<%
if (Registros_isEmpty) {
tempInforme += "No hay resultados que mostrar";
} else {
String reg_CC = "";
String reg_ext = "";
String reg_tipo = "";
String reg_dia = "";
String reg_llamadas = "";
String reg_duracion = "";
String sImporte = "";
StringBuffer tAno = new StringBuffer(4);
StringBuffer tMes = new StringBuffer(2);
StringBuffer tDia = new StringBuffer(2);
while (Registros_hasData) {
reg_CC = Registros.getString(1);
reg_ext = Registros.getString(2);
reg_tipo = Registros.getString(3);
reg_dia = Registros.getString(4);
reg_llamadas = Registros.getString(5);
reg_duracion = Registros.getString(6);
Double reg_importe = new Double((double)Math.round(Registros.getDouble(7)*1 00)/100);
sImporte = reg_importe.toString().replace('.',',');
tAno.delete(0,4);
tMes.delete(0,2);
tDia.delete(0,2);
for (int i=0; i <= 3; i++){
tAno.append(reg_dia.charAt(i));
}
ano = tAno.toString();
for (int i=4; i <= 5; i++){
tMes.append(reg_dia.charAt(i));
}
mes = tMes.toString();
for (int i=6; i <= 7; i++){
tDia.append(reg_dia.charAt(i));
}
dia = tDia.toString();
if(reg_ext.equals("-1")){
tempInforme += ano + "/" + mes + "/" + dia + "\t" + reg_CC + "\t" + "TPI Gen&eacute;rico Madrid\t"+ reg_tipo + "\t" + reg_llamadas + "\t" + reg_duracion + "\t" + sImporte + "\n";
} else if(reg_ext.equals("-2")){
tempInforme += ano + "/" + mes + "/" + dia + "\t" + reg_CC + "\t" + "TPI Gen&eacute;rico Barcelona\t" + reg_tipo + "\t" + reg_llamadas + "\t" + reg_duracion + "\t" + sImporte + "\n";
} else if(reg_ext.equals("-3")){
tempInforme += ano + "/" + mes + "/" + dia + "\t" + reg_CC + "\t" + "Televenta Madrid\t" + reg_tipo + "\t" + reg_llamadas + "\t" + reg_duracion + "\t" + sImporte + "\n";
} else if(reg_ext.equals("-4")){
tempInforme += ano + "/" + mes + "/" + dia + "\t" + reg_CC + "\t" + "Televenta Barcelona\t" + reg_tipo + "\t" + reg_llamadas + "\t" + reg_duracion + "\t" + sImporte + "\n";
} else if(reg_ext.equals("-9")){
tempInforme += ano + "/" + mes + "/" + dia + "\t" + reg_CC + "\t" + "Desconocido\t" + reg_tipo + "\t" + reg_llamadas + "\t" + reg_duracion + "\t" + sImporte + "\n";
} else {
tempInforme += ano + "/" + mes + "/" + dia + "\t" + reg_CC + "\t" + reg_ext + "\t" + reg_tipo + "\t" + reg_llamadas + "\t" + reg_duracion + "\t" + sImporte + "\n";
}
acumNumeroLlamadas += Registros.getInt(5);
acumTotalSegundos += Registros.getInt(6);
acumImporte += Registros.getDouble(7);
Registros_hasData = Registros.next();
}

Double dAcumImporte = new Double((double)Math.round(acumImporte*100)/100);
String sAcumImporte = dAcumImporte.toString().replace('.',',');
tempInforme += "TOTAL\t\t\t\t" + acumNumeroLlamadas + "\t" + acumTotalSegundos + "\t" + sAcumImporte + "\n";
}

//Escritura de archivo
String dirInforme = "/files/temp";
String rutaInforme = "webapps/tarific/files/temp/" + nombreInforme;
BufferedWriter salidaInforme = new BufferedWriter(new FileWriter(rutaInforme));
File ficheroInforme = new File(rutaInforme);
salidaInforme.write(tempInforme);
salidaInforme.close();
if (ficheroInforme.exists()){
%>
<do:download file="<%=nombreInforme%>" dir="<%=dirInforme%>"/>
<%
}
Registros.close();
StatementRegistros.close();
ConnRegistros.close();
%>