【FAQ】【JSP】HTTP Status 500 - Summary(问题排查时候应该仔细分析全部的错误打印说明)

Question 1HTTP Status 500 - Unable to compile class for JSP:'***' cannot be resolved to a typehtml

缘由分析:cannot be resolved to a type 基本上是该类没有被识别出来,编译的时候,编译路径下没有该类对应的库文件,java

解决方法:mysql

一、拷贝类对应的jar到tomcat lib目录下:C:\Program Files\Java\apache-tomcat-8.0.9\libsql

二、关闭tomcat服务器:执行bat文件 C:\Program Files\Java\apache-tomcat-8.0.9\bin\shutdown.bat数据库

三、从新启动tomcat服务器,从新访问页面,该问题现象消失apache

Question 2HTTP Status 500 - invalid driver class name: "java.lang.ClassNotFoundException: com.mysql.jdbc.Driver"windows

缘由分析:JSP程序访问mysql数据库,没有正确识别mysql的jdbc驱动,经过检查发现,当前windows系统并未安装mysql的jsp程序驱动tomcat

解决方法:服务器

一、下载驱动包:在mysql官网上或者在百度中搜索jsp

二、拷贝mysql-connector-java-5.1.22-bin.jar到apache-tomcat的lib文件夹下(C:\Program Files\Java\apache-tomcat-8.0.9\lib)

三、关闭tomcat服务器:执行bat文件 C:\Program Files\Java\apache-tomcat-8.0.9\bin\shutdown.bat

四、从新启动tomcat服务器,从新访问页面,该问题现象消失

Question 3HTTP Status 500 - javax.servlet.ServletException: javax.servlet.jsp.JspException: org.xml.sax.SAXParseException; systemId: jstl:; lineNumber: 1; columnNumber: 1; 前言中不容许有内容。

解决方法:此问题是出如今使用JSP程序访问XML文件的时候,

在使用xml标签前,你必须将XML 和 XPath 的相关包拷贝至你的<Tomcat 安装目录>\lib下:

XercesImpl.jar:下载地址:http://www.apache.org/dist/xerces/j/Xerces-J-tools.2.11.0.zip

xalan.jar:下载地址: http://mirrors.cnnic.cn/apache/xalan/xalan-j/binaries/xalan-j_2_7_2-bin.zip 

添加xml的jar库文件以后:现象消失。

Question 4HTTP Status 500 - javax.servlet.ServletException: javax.servlet.jsp.JspException: org.xml.sax.SAXParseException; systemId: jstl:; lineNumber: 1; columnNumber: 1; Content is not allowed in prolog.

产生异常的运行代码: 

 1 <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
 2 <%@ taglib prefix="x" uri="http://java.sun.com/jsp/jstl/xml" %>
 3 <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
 4     pageEncoding="ISO-8859-1"%>
 5 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
 6 <html>
 7 <head>
 8 <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
 9 <title>XML Data(JSTL x:parse Tags)</title>
10 </head>
11 <body>
12     <h3>Books Information</h3>
13     <c:import var="bookinfo" url="http://localhost:8080/SimpleJspWeb/books.xml"/>
14     <x:parse xml="$(bookinfo)" var="output"/>
15     <b>The title of the first book is</b>:
16     <x:out select="$output/books/book[1]/name"/>
17     <br>
18     <b>The price of the second book is</b>;
19     <x:out select="$output/books/book[2]/price"/>
20 </body>
21 </html>

问题缘由:<x:parse xml="$(bookinfo)" var="output"/> 中的xml内容编写错误,括号使用错误,正确的应该是中括号。以下:
<x:parse xml="${bookinfo}" var="output"/> 

参考:

http://blog.sina.com.cn/s/blog_6d5d8b580100txon.html

http://blog.csdn.net/jaysuper/article/details/5824138

Question 5、XML文件告警:No grammar constraints (DTD or XML Schema) referenced in  the document.

在XML文件头添加:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/2002/xmlspec/dtd/2.10/xmlspec.dtd">

Question 6HTTP Status 500 - /CustomTag.jsp (line: 11, column: 1) The TLD for the class com.tutorialspoint.HelloTag specifies an invalid body-content (JSP) for a SimpleTag.

 缘由很明显:在HelloTag类中指定了一个不可用的的body-content(JSP),检查相应的tld文件,发现未设置body-content属性。在tld文件中添加如下代码:

<body-content>empty</body-content>

Question 7

未完待续。。。

相关文章
相关标签/搜索