[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

JQgrid JSP integration - data not displayed.

Posted on 2010-09-03
3
Medium Priority
?
3,184 Views
Last Modified: 2012-05-10
II am having problem in displaying data in jqGrid when I am building my XML in JSP. Grid is displayed but without any data.

Here is my JSP which connects to DB and create XML.
==============================================================================
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"_http://www.w3.org/TR/html4/loose.dtd">
<%@ page import="java.sql.*" %>
<% Class.forName("oracle.jdbc.driver.OracleDriver");  %>
<% 
	Connection connection = DriverManager .getConnection( "jdbc:oracle:thin:@localhost:test", "test", "test");
	Statement statement = connection.createStatement() ;
	ResultSet resultset = 
	statement.executeQuery("select * from mytable") ; 
%>
<%
	response.ContentType = "text/xml;charset=utf-8" 
%>
<% out.println("&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;"); %>
<% 
   out.println("&lt;invoices&gt;");
   out.println("&lt;rows&gt;");
   while(resultset.next()){
	 out.println("&lt;row&gt;");
	 out.println("&lt;cell&gt;"+resultset.getString(1)+"&lt;/cell&gt;");
	 out.println("&lt;cell&gt;"+resultset.getString(2)+"&lt;/cell&gt;");
	 out.println("&lt;cell&gt;"+resultset.getString(3)+"&lt;/cell&gt;");
	 out.println("&lt;cell&gt;"+resultset.getString(4)+"&lt;/cell&gt;");
	 out.println("&lt;/row&gt;");
   } 
   out.println("&lt;/rows&gt;"); 
   out.println("&lt;/invoices&gt;");
 %>

Open in new window

]=================================================================================

Here is my other JSP which should display data in JQGrid.

==========================================================
<html>
<head>
<title>jqGrid Demo</title>
<link rel="stylesheet" type="text/css" media="screen" href="themes/basic/grid.css" />
<link rel="stylesheet" type="text/css" media="screen" href="themes/jqModal.css" />
<script src="js/jquery.js" type="text/javascript"></script>
<script src="js/jquery.jqGrid.js" type="text/javascript"></script>
<script src="js/jqModal.js" type="text/javascript"></script>
<script src="js/jqDnR.js" type="text/javascript"></script>
<script>

<%
response.ContentType = "text/xml;charset=utf-8" 
%>

jQuery(document).ready(function ()
{ jQuery("#list1").jqGrid({ 
    url:'RetrieveData.jsp',
	datatype: "xml",
	 mtype: 'POST',
    colNames:['Inv No','Date', 'Amount','Tax'],
    colModel :[ 
      {name:'invid', index:'invid', width:55, sorttype:'int'}, 
      {name:'invdate', index:'invdate', width:90, sorttype:'date', datefmt:'Y-m-d'}, 
      {name:'amount', index:'amount', width:80, align:'right', sorttype:'float'}, 
      {name:'tax', index:'tax', width:80, align:'right', sorttype:'float'}
     ],
  rowNum:10, 
  autowidth: true, 
  rowList:[10,20,30], 
  pager: jQuery('#pager1'), 
  sortname: 'id', 
  viewrecords: true, 
  sortorder: "desc", 
  caption:"XML Example" 
  }); 
}); 
</script>


</head>
<body> 
<table id="list1" class="scroll"></table> 
<div id="pager1" class="scroll" style="text-align:center;"></div> 
</body> 
</html>

Open in new window

=================================================================================

Above example works if I get the data from static XML file (i.e. - url:'RetrieveData.xml',
). Any suggestion/help would be appreciated.

Thanks
~P


0
Comment
Question by:pramathur
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
3 Comments
 
LVL 82

Accepted Solution

by:
leakim971 earned 2000 total points
ID: 33601430
you've a space before the dot here : DriverManager .getConnection
0
 
LVL 82

Expert Comment

by:leakim971
ID: 33601534
The following RetrieveData.jsp work for me :

(the JSP displaying the data in JQGrid is fine)
<%@ page contentType="text/xml" %>
<%@ page import="java.sql.*" %>
<% Class.forName("oracle.jdbc.driver.OracleDriver"); %>
<% 
	Connection connection = DriverManager.getConnection( "jdbc:oracle:thin:@localhost:test", "test", "test");	
	Statement statement = connection.createStatement();
	ResultSet resultset = statement.executeQuery("select * from test"); 
%>

<invoice>
<rows>
<% 
   while(resultset.next()) {
	 out.println("<row>");
	 out.println("<cell>" +resultset.getString(1) + "</cell>");
	 out.println("<cell>" +resultset.getString(2) + "</cell>");
	 out.println("<cell>" +resultset.getString(3) + "</cell>");
	 out.println("<cell>" +resultset.getString(4) + "</cell>");
	 out.println("</row>");
   } 
%>
</rows>
</invoice>

Open in new window

0
 
LVL 82

Expert Comment

by:leakim971
ID: 33907133
Thanks for the points!
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Desired Skill Set for Microsoft Dynamics CRM Technical Resources – Part III
With its various features, Office 365 can not only help you with your day-to-day business tasks, it can also do wonders for your marketing campaign.
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question