Ver Mensaje Individual
  #11 (permalink)  
Antiguo 03/05/2010, 14:09
Avatar de HaroldV
HaroldV
 
Fecha de Ingreso: enero-2010
Ubicación: Maracaibo
Mensajes: 100
Antigüedad: 14 años, 10 meses
Puntos: 3
Respuesta: Como Mostrar Datos en un JqGrid()

Cita:
Iniciado por HaroldV Ver Mensaje
Amigos lo que llevo hasta los momentos es esto practicamente parecido a lo que hizo este pana http://dahicotux.wordpress.com/2010/...id-plugin-jsp/
Código:
<%-- 
    Document   : mostrarHumedad
    Created on : 26/04/2010, 11:12:47 AM
    Author     : haroldv
--%>


<%@ page import="java.sql.*" %>
<%@ page import="java.util.*" %>
<%@ page import="java.io.*" %>
<%@ page import="javax.sql.*" %>
<%@ page import="Clases.BaseDatos" %>
<%@ page contentType="text/xml" %>

<%


    String driver = "org.postgresql.Driver";

    String connectString = "jdbc:postgresql://localhost/dptoclimatologia";

    String user = "postgres";

    String password = "17636325";

    Class.forName(driver).newInstance();

    Connection conn = DriverManager.getConnection(connectString, user,password);

    ResultSet rst = conn.createStatement().executeQuery("select id, fecha from humedad");

%>


<%

response.setContentType("text/xml");
response.setCharacterEncoding("utf-8");
response.setHeader("Pragma", "no-cache");
response.setHeader("Cache-Control", "no-cache");
String xml="";

xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?> \n\n";
xml= xml + "<root>\n";
xml = xml + "<rows>\n";

 while(rst.next()){
      System.out.println("HOLABOBO");
         xml= xml +"<row id = "+rst.getInt("id")+">\n   " +
                    "<cell>"+rst.getInt("id")+"</cell>\n     " +
                    " <cell>"+rst.getString("fecha")+"</cell>\n     " +
                " </row>\n";

}
xml = xml +"</rows>\n";
xml = xml + "</root>";
System.out.println(xml);
%>
y Me Muestra esto
Código:
<?xml version="1.0" encoding="UTF-8"?> 


<root>
<rows>
<row id = 1>
   <cell>1</cell>
      <cell>2010/02/04</cell>
      </row>
<row id = 3>
   <cell>3</cell>
      <cell>2010/11/11</cell>
      </row>
<row id = 4>
   <cell>4</cell>
      <cell>2010/06/09</cell>
      </row>
<row id = 5>
   <cell>5</cell>
      <cell>2010/02/01</cell>
      </row>
<row id = 6>
   <cell>6</cell>
      <cell>2010/06/02</cell>
      </row>
<row id = 7>
   <cell>7</cell>
      <cell>2010/05/02</cell>
      </row>
<row id = 8>
   <cell>8</cell>
      <cell>2010/05/17</cell>
      </row>
<row id = 9>
   <cell>9</cell>
      <cell>2010/03/23</cell>
      </row>
<row id = 10>
   <cell>10</cell>
      <cell>2010/04/10</cell>
      </row>
<row id = 11>
   <cell>11</cell>
      <cell>2010/03/18</cell>
      </row>
<row id = 12>
   <cell>12</cell>
      <cell>2010/06/03</cell>
      </row>
<row id = 13>
   <cell>13</cell>
      <cell>2010/02/19</cell>
      </row>
<row id = 14>
   <cell>14</cell>
      <cell>2010/04/31</cell>
      </row>
<row id = 15>
   <cell>15</cell>
      <cell>2010/02/12</cell>
      </row>
<row id = 17>
   <cell>17</cell>
      <cell>2010/07/12</cell>
      </row>
<row id = 16>
   <cell>16</cell>
      <cell>2010/01/01</cell>
      </row>
<row id = 2>
   <cell>2</cell>
      <cell>2010/01/02</cell>
      </row>
<row id = 18>
   <cell>18</cell>
      <cell>2010/01/20</cell>
      </row>
</rows>
</root>
como hago para esos datos asignarlos a un xml creado x mi para que asi al leerlo el JqGrid Los coloque de una vez o como asignarselos de una vez al Jqgrid ?
al llamar a este jsp me sale este error alguien sabe cual es el problema ?
Código:
03/05/2010 03:27:54 PM org.apache.catalina.core.StandardWrapperValve invoke
GRAVE: Servlet.service() para servlet jsp lanzó excepción
java.io.IOException: Stream closed
        at org.apache.jasper.runtime.JspWriterImpl.ensureOpen(JspWriterImpl.java:204)
        at org.apache.jasper.runtime.JspWriterImpl.flushBuffer(JspWriterImpl.java:115)
        at org.apache.jasper.runtime.PageContextImpl.release(PageContextImpl.java:188)
        at org.apache.jasper.runtime.JspFactoryImpl.internalReleasePageContext(JspFactoryImpl.java:118)
        at org.apache.jasper.runtime.JspFactoryImpl.releasePageContext(JspFactoryImpl.java:77)
        at org.apache.jsp.mostrarHumedad_jsp._jspService(mostrarHumedad_jsp.java:214)
        at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
        at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)
        at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
        at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
        at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:849)
        at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
        at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:454)
        at java.lang.Thread.run(Thread.java:619)