我是这样做的,建立个jsp文件,放在myapp下,代码如下:
<%@ page contentTpye="text/html;charset=gb2312"%><!--JSP指令标签-->
<%@ page import="java.util.*"%>
<html><!--HTML标记符-->
<body>
<form name="form1" action="instring.jsp" method="post">
<input type="text" name="jcs">
<input type="submit" name="submit" value="提交">
</form>
<%!String s=null;%> <!--变量声明-->
<%//以下为java程序片
s=request.getParameter("jcs");
if(s==null)
{ out.println("Your input is NULL!");
}else
{out.println("your input is:"+s);}
%>
</body>
</html>
是在书上原文抄上去的,然后运行后显示一大串东西,复制如下:
HTTP状态500 -
--------------------------------------------------------------------------------
type 异 常 报 告
信 息
描 述 服务器遇到内部错误,无法满足这个访问请求
异 常
org.apache.jasper.JasperException: /myapp/instring.jsp(1,1) Page directive has invalid attribute: contentTpye
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:510)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:375)
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)
起 因
org.apache.jasper.JasperException: /myapp/instring.jsp(1,1) Page directive has invalid attribute: contentTpye
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:166)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:295)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:276)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:264)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:563)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:303)
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)
注 意 完整的起因在Apache Tomcat/5.5.17里。
看不懂是怎么回事,先前个最简单的jsp能运行成功,如:
<html><body><center>
Now time is: <%=new java.util.Date()%>
</center></body></html>
高手们帮看看是什么问题呢,谢谢