主题:JSP程序无法运行
小弟刚学不久.到网上去下了tomcat和jdk安装以后,又随便找了个程序来实验一下。
<%@ page contenType="text/html; charset=gb2312"%>
<%@ page import="java.util.*"%>
<html>
<head>
<title>yanshi</title>
</head>
<body>
<h2 align="center">duixiangyanshi</h2>
<%
String appAttrib;
int count=0;
Enumeration attributes=pageContext.getAttributeNamesinScope(pageContext.APPLICATION_SCOPE);
while(attributes.hasMoreElement())
{
count +=1;
appAttrib=(String)attributes.nextElemnt();
out.print("Application属性" +count+ ":" +appAttrib+ "<br>");
}
%>
</body>
</html>
可是一用http://localhost:8080/s3.jsp打开就出现
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: /s3.jsp(1,1) Page directive has invalid attribute: contenType
org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:39)
org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:405)
org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:196)
org.apache.jasper.compiler.JspUtil.checkAttributes(JspUtil.java:304)
org.apache.jasper.compiler.Validator$DirectiveVisitor.visit(Validator.java:100)
org.apache.jasper.compiler.Node$PageDirective.accept(Node.java:549)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2163)
org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2213)
org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2219)
org.apache.jasper.compiler.Node$Root.accept(Node.java:456)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2163)
org.apache.jasper.compiler.Validator.validate(Validator.java:1452)
org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:157)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:286)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:267)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:255)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:563)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:293)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
note The full stack trace of the root cause is available in the Apache Tomcat/5.5.12 logs.
--------------------------------------------------------------------------------
Apache Tomcat/5.5.12
不知是何原因.我也去配置过环境变量了
<%@ page contenType="text/html; charset=gb2312"%>
<%@ page import="java.util.*"%>
<html>
<head>
<title>yanshi</title>
</head>
<body>
<h2 align="center">duixiangyanshi</h2>
<%
String appAttrib;
int count=0;
Enumeration attributes=pageContext.getAttributeNamesinScope(pageContext.APPLICATION_SCOPE);
while(attributes.hasMoreElement())
{
count +=1;
appAttrib=(String)attributes.nextElemnt();
out.print("Application属性" +count+ ":" +appAttrib+ "<br>");
}
%>
</body>
</html>
可是一用http://localhost:8080/s3.jsp打开就出现
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: /s3.jsp(1,1) Page directive has invalid attribute: contenType
org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:39)
org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:405)
org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:196)
org.apache.jasper.compiler.JspUtil.checkAttributes(JspUtil.java:304)
org.apache.jasper.compiler.Validator$DirectiveVisitor.visit(Validator.java:100)
org.apache.jasper.compiler.Node$PageDirective.accept(Node.java:549)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2163)
org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2213)
org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2219)
org.apache.jasper.compiler.Node$Root.accept(Node.java:456)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2163)
org.apache.jasper.compiler.Validator.validate(Validator.java:1452)
org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:157)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:286)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:267)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:255)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:563)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:293)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
note The full stack trace of the root cause is available in the Apache Tomcat/5.5.12 logs.
--------------------------------------------------------------------------------
Apache Tomcat/5.5.12
不知是何原因.我也去配置过环境变量了