JSP tomcat 不能编译,请高手指点。
本人初学 jsp,写了个简单的jsp页面,但是tomcat报错,
代码如下:
<%@ page contenttype= "html/text ";charset= "gb2312 " %>
<html>
<head>
求平方根
</head>
<body>
<p> 请输入一个正数,点击按钮求平方根:
<center>
<form action= " " method =post name =form>
<input type = "text " name = "ok ">
<br> <input type = "submit " value= "送出 " name= "submit ">
</form>
<% String str=requst.getparameter( "ok ");
if(str==null){
str = "1 ";
}
try{
double number = Integer.parseInt(str);
out.println(Math.Sqrt(number));
}
catch(Exception e){
out.println( "请出入数字 ");
}
%>
</center>
</body>
</html>
出错信息:
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: /cpt.jsp(13,3) Unterminated <% tag
org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:39)
org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:409)
org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:134)
org.apache.jasper.compiler.Parser.parseScriptlet(Parser.java:796)
org.apache.jasper.compiler.Parser.parseElements(Parser.java:1551)
org.apache.jasper.compiler.Parser.parse(Parser.java:126)
org.apache.jasper.compiler.ParserController.doParse(ParserController.java:220)
org.apache.jasper.compiler.ParserController.parse(ParserController.java:101)
org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:203)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:470)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:451)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:439)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:511)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:295)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
note The full stack trace of the root cause is available in the Apache Tomcat/5.0.28 logs.
------解决方案--------------------根据错误来看你的这一句 <%@ page contenttype= "html/text ";charset= "gb2312 " %> 有问题
删掉它或者改为
<%@ page contentType= "html/text;charset=gb2312 " %>
我的异常网推荐解决方案:The server encountered an internal error () that prevented it from fulfilling this request.,http://www.aiyiweb.com/java-web/317.html