У меня есть следующий файл JSP, в котором я создаю jsGrid для манипулирования данными на моем сервере.Почему-то я не могу запустить его.
<%@page language="java" contentType="text/javascript; charset=windows-1255"
import="com.dstm.mp.web.event.IServletConstants"
import="com.dstm.mp.web.model.base.SessionUser"
import="javax.naming.Context"
import="javax.naming.InitialContext"
import="java.sql.Connection"
import="java.sql.DatabaseMetaData"
import="java.sql.ResultSet"
import="java.sql.SQLException"
import="java.sql.Statement"
import="javax.sql.DataSource"
%>
<%@page import="hu.eam.dbtools.DBHandler"%>
<%@page import="java.util.Map"%>
<%@page import="java.util.Properties"%>
<%@page import="java.util.ArrayList"%>
<%@page import="ChartDirector.*" %>
<% String address = "http://192.168.10.48/docuploads/ROADS"; %>
<%
String[] astrUpscode = { "" };
String strOrder = request.getParameter("WORKORDERNUM");
String strOrg = request.getParameter("ORGANIZATION");
String SQL = ---Some sql query-- ;
String ObjectsSQL = ---Some sql query--;
ArrayList ObjectsList = null;
ArrayList Aspects = null;
ArrayList EventEntries = null;
SessionUser sessionUser = (SessionUser)session.getAttribute(IServletConstants.USER_BEAN);
if (sessionUser != null)
{
InitialContext initialContext = new InitialContext();
Context context = (Context)initialContext.lookup("java:/comp/env");
if (context != null)
{
try
{
DataSource ds = (DataSource)context.lookup("jdbc/" + sessionUser.getTenantId());
if (ds != null)
{
DBHandler handler = new DBHandler(ds);
ResultSet rs = handler.doQuery(SQL, null);
ObjectsList = new ArrayList();
EventEntries = new ArrayList();
while (rs.next())
{
String ObjectEntry = rs.getString("OBJECT_CODE") +":"+ rs.getString("OBJECT_DESC");
if(!ObjectsList.contains(ObjectEntry))
ObjectsList.add(ObjectEntry);
Object[] EventEntry = new Object[4];
EventEntry[1] = rs.getString("DEF_CODE");
EventEntry[2] = rs.getInt("SEV");
EventEntry[0] = rs.getString("OBJECT_CODE");
EventEntry[3] = rs.getString("EXT");
EventEntries.add(EventEntry);
}
handler.close();
}
else out.println("no datasource<br>");
}
catch (Exception e)
{
out.println("exception=" + e.getMessage() + "<br>");
}
}
else out.println("no context<br>");
out.println("<br>");
out.println("<br>");
}
else
{
out.println("no session user");
}
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=windows-1255">
<title>Damage Reporting Grid</title>
<link rel="stylesheet" type="text/css" media="screen" href="css/sunny/jquery-ui-1.8.13.custom.css" />
<link rel="stylesheet" type="text/css" media="screen" href="css/ui.jqgrid.css" />
<style type="text/css">@import "<%=address%>/style.css";</style>
<script src="js/jquery-1.5.2.min.js" type="text/javascript"></script>
<script src="js/i18n/grid.locale-en.js" type="text/javascript"></script>
<script src="js/jquery.jqGrid.min.js" type="text/javascript"></script>
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="Expires" content="-1" />
<meta http-equiv="Cache-Control" content="no-cache" />
<meta http-equiv="Content-Language" content="he">
</head>
<body>
<%
out.println("ObjectsList: "+ObjectsList.size()+"<br>");
out.println("EventEntries: "+EventEntries.size()+"<br>");
%>
<table id="GridReporting"></table>
<div id="Pager"></div>
<input type="BUTTON" id="buttonAdd" value="Add" />
<input type="BUTTON" id="buttonAdd" value="Save Changes" />
<script type="text/javascript">
var lastsel2;
jQuery("#GridReporting").jqGrid({
url:'local',
height: 250,
colNames:['Part','Point', 'Event', 'Severity','Perimeter','Note', 'Image 1', 'Image 2'],
colModel:[
{ name:'part',
index:'part',
width:60 ,
editable:true,
edittype:"select",
editoptions:{
value:"<%
if(ObjectsList != null)
{
out.print(ObjectsList.get(0));
for( int i = 1 ; i < ObjectsList.size(); ++i)
{
out.print(";"+ObjectsList.get(i));
}
}
%>",
dataEvents: [{
type: 'change',
fn: function(e) {
jQuery("#GridReporting").jqGrid('saveRow',lastsel2,true);
}
}]
}
},
{ name:'event',
index:'event',
width:100,
editable:true,
edittype:"select",
editoptions:{
value:"Break:Break;Crack:Crack;Bend:Bend",
dataEvents: [{
type: 'change',
fn: function(e) {
jQuery("#GridReporting").jqGrid('saveRow',lastsel2,true);
}
}]
}
},
{ name:'severity',
index:'severity',
width:80,
editable:true,
edittype:"select",
editoptions:{
value:"1:1;2:2;3:3;4:4;5:5",
dataEvents: [{
type: 'change',
fn: function(e) {
jQuery("#GridReporting").jqGrid('saveRow',lastsel2,true);
}
}]
}
},
{ name:'perimeter',
index:'perimeter',
width:80, editable:true
edittype:"select",
editoptions:{
value:"A:A;B:B;C:C;D:D;E:E",
dataEvents: [{
type: 'change',
fn: function(e) {
jQuery("#GridReporting").jqGrid('saveRow',lastsel2,true);
}
}]
}
},
{ name:'note',
index:'note',
width:80,
editable:true,
sortable:false,
edittype:"textarea",
editoptions:{
rows:"5",
cols:"20",
dataEvents: [{
type: 'change',
fn: function(e) {
jQuery("#GridReporting").jqGrid('saveRow',lastsel2,true);
}
}]
}
},
{ name:'image1',
index:'image1',
width:80,
editable:true,
edittype:"select",
editoptions:{
value:"Pic1:Pic1;Pic2:Pic2;Pic3:Pic3;Pic4:Pic4",
dataEvents: [{
type: 'change',
fn: function(e) {
jQuery("#GridReporting").jqGrid('saveRow',lastsel2,true);
}
}]
}
},
{ name:'image2',
index:'image2',
width:150,
editable:true,
edittype:"select",
editoptions:{
value:"Pic21:Pic21;Pic22:Pic22;Pic23:Pic23;Pic24:Pic24",
dataEvents: [{
type: 'change',
fn: function(e) {
jQuery("#GridReporting").jqGrid('saveRow',lastsel2,true);
}
}]
}
}
],
rowNum:10,
autowidth: true,
rowList:[10,20,30],
pager: jQuery('#Pager'),
sortname: 'part',
viewrecords: true,
sortorder: "desc",
onSelectRow: function(id){
if(id && id!==lastsel2){
jQuery('#GridReporting').jqGrid('restoreRow',lastsel2);
jQuery('#GridReporting').jqGrid('editRow',id,true);
lastsel2=id;
}
},
editurl: 'connectToDB.jsp',
caption: "Manipulating Array Data"
}).navGrid('#Pager',{edit:false,add:false,del:false});
$("#buttonAdd").click(function(){
jQuery("#GridReporting").jqGrid('editGridRow',"new",{height:280,reloadAfterSubmit:false});
});
var mydata = [
<%
if(EventEntries != null)
{
for(int i = 0 ; i < EventEntries.size() - 1; ++i)
{
out.println("{part:"+(((Object[])EventEntries.get(i))[0])+
", event:"+(((Object[])EventEntries.get(i))[1])+
", severity:"+(((Object[])EventEntries.get(i))[2])+
",perimeter:"+(((Object[])EventEntries.get(i))[3])+
",note:try, image1:try, image2:try},");
}
int i = EventEntries.size() - 1;
if(i >=0)
{
out.println("{part:"+(((Object[])EventEntries.get(i))[0])+
", event:"+(((Object[])EventEntries.get(i))[1])+
", severity:"+(((Object[])EventEntries.get(i))[2])+
",perimeter:"+(((Object[])EventEntries.get(i))[3])+
",note:try, image1:try, image2:try}");
}
}
%>
];
for(var i=0;i<=mydata.length;i++)
jQuery("#list4").jqGrid('addRowData',i+1,mydata[i]);
</script>
</body>
</html>
Это ошибка, которую я получаю:
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: java.lang.NullPointerException
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:413)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:322)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:249)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
root cause
java.lang.NullPointerException
org.apache.jsp.custjsp.DamageReportingGrid.DamageReportingGrid_jsp._jspService(DamageReportingGrid_jsp.java:197)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:369)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:322)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:249)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
note The full stack trace of the root cause is available in the JBoss Web/2.1.3.GA logs.
Строка 197 не находится в разделе сервера, она находится в части JavaScript, гдеЯ объявляю столбцы jqGrid.Как найти правильную строку в коде JSP?