如果我在netbeans上运行此应用程序,它的工作正常而没有任何错误,但我想在不使用netbeans的情况下运行此Web应用程序(.war)。
我是tomcat的新手并开发了这个web应用程序,我安装了tomcat,带有glassfish的javaEE 6,MY SQL并配置了所有。它的作品在一段时间后开始正常,它会给出这个错误然后我再次刷新它再次起作用,经过一段时间再次重复。
OR
您还可以选择在不使用netbeans的情况下运行此Web应用程序(.war),我想将源代码隐藏到endusers.can,任何人都可以帮助我吗?
type Exception report
message An exception occurred processing JSP page /KichenDisplay.jsp at line 177
description The server encountered an internal error that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: An exception occurred processing JSP page /KichenDisplay.jsp at line 177
174:
175: <%
176: Orders or=new Orders();
177: list=or.getData(activeid);
178: itr=list.iterator();
179: while(itr.hasNext()){
180: ActionForm af=(ActionForm) itr.next();
Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:568)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:470)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:393)
root cause
java.lang.NullPointerException
com.manager.Orders.getData(Orders.java:31)
org.apache.jsp.KichenDisplay_jsp._jspService(KichenDisplay_jsp.java:264)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:393)
note The full stack trace of the root cause is available in the Apache Tomcat/7.0.41 logs.
Apache Tomcat/7.0.41
答案 0 :(得分:0)
这是我使用的源代码
Orders.java
/ *
*要更改此许可证标题,请在“项目属性”中选择“许可证标题”。
*要更改此模板文件,请选择“工具”|模板
*并在编辑器中打开模板。
* /
package com.manager;
import com.manager.Forms.ActionForm;
import com.manager.util.DBConnection;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
*
* @author krishna
*/
public class Orders {
Connection con;
PreparedStatement ps;
ArrayList<ActionForm> list;
public ArrayList<ActionForm> getData(String id) throws SQLException{
DBConnection db=new DBConnection();
con=db.getConn();
list=new ArrayList<ActionForm>();
ps=con.prepareStatement("select item,quantity,status,action,waction from orders where tableid="+id);
ResultSet rs=ps.executeQuery();
while(rs.next()){
list.add(new ActionForm(rs.getString(1),rs.getString(2),rs.getString(3),rs.getString(4),rs.getString(5)));
}
return list;
}
public int getNotification(){
int cnt=0;
try {
DBConnection db=new DBConnection();
Connection con=db.getConn();
PreparedStatement ps=con.prepareStatement("select count(distinct(tableid)) from orders where checkout=1");
ResultSet rs=ps.executeQuery();
if(rs.next()){
cnt=rs.getInt(1);
}
} catch (SQLException ex) {
Logger.getLogger(Orders.class.getName()).log(Level.SEVERE, null, ex);
cnt=0;
}
finally{
return cnt;
}
}
public ArrayList getCheckedOut(){
ArrayList list=new ArrayList();
try{
DBConnection db=new DBConnection();
Connection con=db.getConn();
PreparedStatement ps=con.prepareStatement("select distinct(tableid) from orders where checkout=1");
ResultSet rs=ps.executeQuery();
while(rs.next()){
list.add(rs.getString(1));
}
}
catch(Exception e){}
finally{
return list;
}
}
}
Kitchendisplay.java
<%--
Document : KichenDisplay
Created on : Dec 2, 2013, 5:29:48 PM
Author : admin
--%>
<%@page import="com.manager.Forms.ActionForm"%>
<%@page import="com.manager.Orders"%>
<%@page import="com.manager.Forms.TableForm"%>
<%@page import="java.util.Iterator"%>
<%@page import="java.util.ArrayList"%>
<%@page import="com.manager.Tables"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="Refresh" content="5">
<title><%=getServletContext().getInitParameter("name")%></title>
<link rel="stylesheet" type="text/css" href="css/notification.css" />
<link href="css/modal.css" rel="stylesheet" type="text/css" />
<link href="style.css" rel="stylesheet" type="text/css" />
<link href="css/circles.css" rel="stylesheet" type="text/css" />
<script src="js/jquery.js"></script>
<link href="css/scroll.css" rel="stylesheet" type="text/css" />
<script src="js/getData.js"></script>
<style>
#circl{
width: 52px;
height: 52px;
background:gray;
-moz-border-radius: 500px;
-webkit-border-radius: 500px;
border-radius: 500px;
}
a{
text-decoration: none;
}
</style>
</head>
<body background="images/bg2.png">
<div id="circles"></div>
<script>loadContent()</script>
<!---->
<fieldset style="height:700">
<img src="">
<div style="background: url(images/top.png);width: 100%;height: 100px;margin-top: -20px">
<br>
<img src="images/Dg.png">
</div>
<table style="background: url(images/tabb.png);width: 100%;height: 1px;margin-top: -40px">
<tr>
<%
Orders o=new Orders();
int c1=o.getNotification();
%>
<td style="width:6%;text-align: center;font-size: 13px;text-align: center;margin-top: -40px"><b>
<a href="BillDesk.jsp" Style="color:white">BillDesk</a>
<div class="notification-container">
<!-- <i class="icon-globe"></i>-->
<%if(c1!=0){%>
<span class="notification-counter"><a href="#join_form"><%=c1%></a></span><%}%>
</div>
</b></td>
<td style="width:7%;background: url(images/sbt.png);font-size: 12px;text-align: center"><b>
<FONT COLOR=white><a href="KichenDisplay.jsp" Style="color:black">Kichen Display</a>
</FONT></b></td>
<td style="width:10%;font-size: 14px"><b><FONT COLOR=WHITE><a href="WaiterDisplay.jsp" Style="color:white">Waiter Display</a></FONT></b></td>
<td style="width:6%;font-size: 14px"><b><FONT COLOR=WHITE><a href="menu.jsp" Style="color:white">Menu</a></FONT></b></td>
<td style="width:8%;font-size: 14px"><b><FONT COLOR=WHITE><a href="transactions" Style="color:white">Transaction</a></FONT></b></td>
<td style="width:7%;font-size: 14px"><b><FONT COLOR=WHITE><a href="GetMenu.jsp" Style="color:white">Sync</a></FONT></b></td>
<td><b><FONT COLOR=WHITE><a href="Contact.jsp" Style="color:white;font-size: 15px">Contact Us</a></FONT></b></td>
</tr>
</table><br>
<table>
<tr>
<td>
<div style=color:lightslategray>
Tables
</div>
<fieldset style="margin-left: 30px;background: white">
<div style="margin-left: 5px;margin-left: 1px;background-image: url(images/tab.png);width: 350px;height: 400px">
<table style="margin-left: 25px">
<%
int cnt=0,count=0;
//String c=(String)(session.getAttribute("count")+"");
//if( !c.equals("null") || c!="null" || !c.equals(null) || c!=null)
// cnt=Integer.parseInt(c);
String activeid=request.getParameter("id");
if(activeid==null)
activeid="0";
Tables t=new Tables();
ArrayList list=t.getTables();
Iterator itr=list.iterator();
while(itr.hasNext()){
out.println("<tr>");
for(int i=0;i<5&&itr.hasNext();i++){
TableForm tf=(TableForm)itr.next();
String id=tf.getId();
String ordered=tf.getOrdered();
String color="gray";
boolean f=false;
String img="images/gray.png";
String link="#";
if(ordered.equals("1"))
{
color="green";
f=true;
link="KichenDisplay.jsp?id="+id;
img="images/green.png";
count++;
}
if(activeid.equals(id)){
color="red";
img="images/red.png";
}
session.setAttribute("count",count+"");
%><td>
<a href="<%=link%>" style="text-decoration: none;">
<div style="background:url(<%=img%>)" id="circl">
<p style="width:40px;height: 1px;font-weight: bolder;text-align: center;margin-top: 15px;">
<div style='margin-left: 25px;margin-top: 17px'><%=id%></div>
</p>
</div></a>
</td><%
}
//out.println(itr.next());
out.println("</tr>");
}
%>
</table>
</div>
</fieldset>
<%if(cnt!=count){
System.out.println("cnt:"+cnt+" count:"+count);
out.println("<embed height='0' width='0' src='css/s.mp3'/>");
}
else{
System.out.println("cnt:"+cnt+" count:"+count);
}%>
</td>
<td> <!--embed height="0" width="0" src="css/s.mp3"/>-->
<div style="color:#fffff;margin-top: 00px;overflow-y: auto;height:400px" class="scrollbar">
Table <%=activeid%> Details
<table width="900" style="text-align: center;border:1px solid blue;border-collapse: collapse;">
<th style="border:1px solid blue;">Item name </th>
<th style="border:1px solid blue;">Quantity</th>
<th style="border:1px solid blue;">Status </th>
<th style="border:1px solid blue;">Action </th>
<%
Orders or=new Orders();
list=or.getData(activeid);
itr=list.iterator();
while(itr.hasNext()){
ActionForm af=(ActionForm) itr.next();
String name=af.getName();
String qt=af.getQuantity();
String st=af.getStatus();
String act=af.getKitchenAction();
%>
<tr>
<td style="border:1px solid blue;width:50%"align="left" ><%=name%> </td>
<td style="border:1px solid blue;"><%=qt%></td>
<td style="border:1px solid blue;"><%=st%> </td>
<td style="border:1px solid blue;"><%=act%> </td>
</tr>
<%
}
%>
</table>
</div>
</fieldset>
<a href="#x" class="overlay" id="join_form"></a>
<div class="popup" style="width:200px;height: 300px;">
<h4>Checked out Tables</h4>
<%
ArrayList lst=o.getCheckedOut();
Iterator it1=lst.iterator();
while(it1.hasNext()){
out.println(it1.next()+" is checked out");
}
%>
<a class="close" href="#close"></a>
</div>
</td>
</tr>
</table>
</body>
</html>
答案 1 :(得分:0)
是的,知道了。关闭tomcat的问题关闭了端口,我改变了它,现在它工作正常。