请教:怎么解决这个错误呀The server encountered an internal error () that prevented it from fulfilling this request.

evoloyeu 2008-03-19 04:24:57
错误:
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: An exception occurred processing JSP page /sender.jsp at line 34

31: String msgPrefix[]={"GG","GM","GS","GL"};
32: String feedback="";
33:
34: if(commands.equals("single"))
35: feedback=new String(msgPrefix[0]);
36: if(commands.equals("consequance"))
37: feedback=new String(msgPrefix[1]);


Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:524)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:435)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:390)

root cause

java.lang.NullPointerException
org.apache.jsp.sender_jsp._jspService(sender_jsp.java:84)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:393)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:390)

note The full stack trace of the root cause is available in the Apache Tomcat/6.0.14 logs.
Apache Tomcat/6.0.14

jsp代码:
<%--
Document : sender
Created on : 2008-3-17, 14:01:17
Author : Administrator
--%>

<%@page contentType="text/html;charset=gb2312" pageEncoding="UTF-8"%>
<%@page import="java.util.*"%>
<!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=gb2312">
<title>JSP Page</title>
</head>
<body>

<form method="POST" action="">
绑定用户ID:<input type="text" name="userPhone" value="" /><br>
绑定命令:<input type="text" name="command" value="" /><br>
<input type="radio" name="command" value="single" />单次定位
<input type="radio" name="command" value="consequance" />连续定位
<input type="radio" name="command" value="cease" />停止连续定位
<input type="radio" name="command" value="shutLED" />关闭定位器LED<br>
<input type="reset" value="重置" name="reset" />
<input type="submit" value="提交" name="submit" /><br>
</form>
<%
String commands=request.getParameter("command");
//String userPhone=request.getParameter("userPhone");
String msgPrefix[]={"GG","GM","GS","GL"};
String feedback="";

if(commands.equals("single"))
feedback=new String(msgPrefix[0]);
if(commands.equals("consequance"))
feedback=new String(msgPrefix[1]);
if(commands.equals("cease"))
feedback=new String(msgPrefix[2]);
if(commands.equals("shutLED"))
feedback=new String(msgPrefix[3]);
%>
<jsp:useBean id="sender" class="Bean.Sender" scope="page"/>
<jsp:setProperty name="sender" property="userPhone" param="userPhone"/>
<jsp:setProperty name="sender" property="sendData" param="<%=feedback%>"/>

<jsp:getProperty name="sender" property="sendData"/>
<%
//sender.sendCommands();
%>
<h2>first try,Hello World!</h2>
</body>
</html>


javabean代码:
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/

package Bean;
import java.net.*;
import java.io.*;
/**
*
* @author Administrator
*/
public class Sender {
private String sendData;
private String userPhone;
public void setSendData(String sendData){this.sendData=sendData;}
public void setAdd(String add){this.userPhone=add;}
public String getSendData(){return this.sendData;}
public String getAdd(){return this.userPhone;}
public Sender(){ }
/*public void sendCommands(){
if(sendData!=null){
byte buffer[]=sendData.getBytes();
try{
InetAddress address=InetAddress.getByName(this.userPhone);
DatagramPacket sendPack=new DatagramPacket(buffer,buffer.length,address,9999);//server receiver port:8888
DatagramSocket sendSocket=new DatagramSocket();
sendSocket.send(sendPack);
}catch(Exception e){e.printStackTrace();}
}
}*/
}
...全文
2198 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
adlop 2009-07-31
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 evoloyeu 的回复:]
自己找出来了哈。。。。。。
将jsp里的java代码改一下就可以了:
将            if(commands.equals("single"))
                feedback=new String(msgPrefix[0]);
            if(commands.equals("consequance"))
                feedback=new String(msgPrefix[1]);
            if(commands.equals("cease"))
                feedback=new String(msgPrefix[2]);
            if(commands.equals("shutLED"))
                feedback=new String(msgPrefix[3]);
改为;
            if(commands!=null)
            {
                if(commands.equals("single"))
                    feedback=new String(msgPrefix[0]);
                if(commands.equals("consequance"))
                    feedback=new String(msgPrefix[1]);
                if(commands.equals("cease"))
                    feedback=new String(msgPrefix[2]);
                if(commands.equals("shutLED"))
                    feedback=new String(msgPrefix[3]);
            }
[/Quote]
evoloyeu 2008-04-14
  • 打赏
  • 举报
回复
结贴
evoloyeu 2008-03-19
  • 打赏
  • 举报
回复
自己找出来了哈。。。。。。
将jsp里的java代码改一下就可以了:
将 if(commands.equals("single"))
feedback=new String(msgPrefix[0]);
if(commands.equals("consequance"))
feedback=new String(msgPrefix[1]);
if(commands.equals("cease"))
feedback=new String(msgPrefix[2]);
if(commands.equals("shutLED"))
feedback=new String(msgPrefix[3]);
改为;
if(commands!=null)
{
if(commands.equals("single"))
feedback=new String(msgPrefix[0]);
if(commands.equals("consequance"))
feedback=new String(msgPrefix[1]);
if(commands.equals("cease"))
feedback=new String(msgPrefix[2]);
if(commands.equals("shutLED"))
feedback=new String(msgPrefix[3]);
}

10,608

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 其他
社区管理员
  • 其他
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧