JSP编译错误!困饶一天了,高手帮忙!

yangxinlei 2007-12-28 05:07:12
原文件如下:
<%@include file="jsp/ip.jsp"%>
<%@ page contentType="text/html;charset=gb2312"%>
<%@ page import="java.util.*"%>
<%@ page import="java.sql.*"%>
<%@ page import="java.text.*"%>
<%@ page import="java.util.Date.*" %>
<%@ page import="java.net.*" %>
<%@ page import="javax.sql.*" %>
<%@ page import="javax.naming.*" %>
<%

//接受参数
String username = request.getParameter("textfield");
String mypassword = request.getParameter("textfield1");

username = username.trim();
mypassword = mypassword.trim();

int count = username.length();
int count1 = mypassword.length();

//验证参数
if (count<1||count1<1) {
%>
<script language="javascript">
alert("用户名或密码不能为空,请您重新输入!");
javascript:history.go(-1);
</script>
<%
}
else {
//对象初始化
DataSource ds = null;
Statement stmt = null;
Connection cn = null;
ResultSet rs = null;
try {
//初始化context
Context initCtx = new InitialContext();
Context envCtx = (Context) initCtx.lookup("java:comp/env");

//获取连接池对象并进行类型转换
ds = (DataSource)envCtx.lookup("jdbc/c3po");

String sql = "";
sql = "SELECT test_count FROM test_count WHERE test_user = '"+ username +"'";

//执行定义好的语句
try {
if(ds != null) {
cn = ds.getConnection();
if(cn != null) {
stmt = cn.createStatement();
rs = stmt.executeQuery(sql);
}else {
System.out.println("连接获取失败!");
}
}else {
System.out.println("数据源获取失败!");
}
}catch(Exception e) {
System.out.println(e);
}

//获得相应用户名的密码
String temppassword = "";
while(rs.next()) {
temppassword = rs.getString("test_count");
temppassword = temppassword.trim();
}

//进行判断,如果获得的密码与前面的相符,则进入后续页面,否则跳转到登陆页面
if(temppassword.equals(mypassword)) {
session.setAttribute("ValUsername",username);
session.setAttribute("ValPassword",mypassword);
response.sendRedirect("index1.jsp");
return;
}
else {
%>
<script language="javascript">
alert("用户名或密码不正确!请您重新输入!");
javascript:history.go(-1);
</script>
<%
}

//释放数据库连接
stmt.close();
cn.close();
}
catch(Exception e) {
System.out.print("系统异常,需要处理 ");
System.out.println(e.getMessage());
}finally {
try {
if(stmt != null) {
stmt.close();
stmt = null;
}
if(cn != null) {
cn.close();
cn = null;
}

}catch(Exception e) {
System.out.println(e);
}
}
%>

-----------------------------------------------------------------------------------
运行后报了以下错误:
[COVALENT-DEBUG] JSP Compile Error:
JSP FileName:null
Java FileName:/E:/apache-tomcat-5.5.25/work/Catalina/localhost/ota//org/apache/jsp\test_jsp.java


An error occurred at line: 169 in the generated java file
Syntax error, insert "}" to complete Block
JSP FileName:null
Java FileName:/E:/apache-tomcat-5.5.25/work/Catalina/localhost/ota//org/apache/jsp\test_jsp.java


An error occurred at line: 179 in the generated java file
Syntax error on token "}", delete this token
JSP FileName:null
Java FileName:/E:/apache-tomcat-5.5.25/work/Catalina/localhost/ota//org/apache/jsp\test_jsp.java


An error occurred at line: 180 in the generated java file
Syntax error, insert "}" to complete ClassBody
2007-12-28 16:55:12 org.apache.catalina.core.StandardWrapperValve invoke
严重: Servlet.service() for servlet jsp threw exception
org.apache.jasper.JasperException: Unable to compile class for JSP:
JSP FileName:null
Java FileName:/E:/apache-tomcat-5.5.25/work/Catalina/localhost/ota//org/apache/jsp\test_jsp.java


An error occurred at line: 169 in the generated java file
Syntax error, insert "}" to complete Block
JSP FileName:null
Java FileName:/E:/apache-tomcat-5.5.25/work/Catalina/localhost/ota//org/apache/jsp\test_jsp.java


An error occurred at line: 179 in the generated java file
Syntax error on token "}", delete this token
JSP FileName:null
Java FileName:/E:/apache-tomcat-5.5.25/work/Catalina/localhost/ota//org/apache/jsp\test_jsp.java


An error occurred at line: 180 in the generated java file
Syntax error, insert "}" to complete ClassBody

2007-12-28 16:55:12 org.apache.catalina.core.StandardWrapperValve invoke
严重: Servlet.service() for servlet jsp threw exception
java.lang.ClassNotFoundException: org.apache.jsp.test_jsp
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:131)
at org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:63)
at org.apache.jasper.JspCompilationContext.load(JspCompilationContext.java:597)
at org.apache.jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java:137)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:314)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:174)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:151)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:874)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:689)
at java.lang.Thread.run(Unknown Source)
-------------------------------------------------------------------------
高手指点~~~~另外,上头说少了个},我怎么也找不出来~
...全文
224 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
ACER 2011-08-01
  • 打赏
  • 举报
回复
各位编程大师们 俺是新来的菜鸟,求个 师父 带带
ACER 2011-08-01
  • 打赏
  • 举报
回复
求 师父
chjx1982 2007-12-28
  • 打赏
  • 举报
回复
这个页面是不是直接报错了,还是编译以后再出错,看那个错误信息应该是编译之前就已经错误了。
aguai0 2007-12-28
  • 打赏
  • 举报
回复
<%@include file="jsp/ip.jsp"%>
<%@ page contentType="text/html;charset=gb2312"%>
<%@ page import="java.util.*"%>
<%@ page import="java.sql.*"%>
<%@ page import="java.text.*"%>
<%@ page import="java.util.Date.*" %>
<%@ page import="java.net.*" %>
<%@ page import="javax.sql.*" %>
<%@ page import="javax.naming.*" %>
<%

//接受参数
String username = request.getParameter("textfield");
String mypassword = request.getParameter("textfield1");

username = username.trim();
mypassword = mypassword.trim();

int count = username.length();
int count1 = mypassword.length();

//验证参数
if (count <1 ||count1 <1) {
%>
<script language="javascript">
alert("用户名或密码不能为空,请您重新输入!");
javascript:history.go(-1);
</script>
<%
}
else {
//对象初始化
DataSource ds = null;
Statement stmt = null;
Connection cn = null;
ResultSet rs = null;
try {
//初始化context
Context initCtx = new InitialContext();
Context envCtx = (Context) initCtx.lookup("java:comp/env");

//获取连接池对象并进行类型转换
ds = (DataSource)envCtx.lookup("jdbc/c3po");

String sql = "";
sql = "SELECT test_count FROM test_count WHERE test_user = '"+ username +"'";

//执行定义好的语句
try {
if(ds != null) {
cn = ds.getConnection();
if(cn != null) {
stmt = cn.createStatement();
rs = stmt.executeQuery(sql);
}else {
System.out.println("连接获取失败!");
}
}else {
System.out.println("数据源获取失败!");
}
}catch(Exception e) {
System.out.println(e);
}

//获得相应用户名的密码
String temppassword = "";
while(rs.next()) {
temppassword = rs.getString("test_count");
temppassword = temppassword.trim();
}

//进行判断,如果获得的密码与前面的相符,则进入后续页面,否则跳转到登陆页面
if(temppassword.equals(mypassword)) {
session.setAttribute("ValUsername",username);
session.setAttribute("ValPassword",mypassword);
response.sendRedirect("index1.jsp");
return;
}
else {
%>
<script language="javascript">
alert("用户名或密码不正确!请您重新输入!");
javascript:history.go(-1);
</script>
<%
}

//释放数据库连接
stmt.close();
cn.close();
}
catch(Exception e) {
System.out.print("系统异常,需要处理 ");
System.out.println(e.getMessage());
}finally {
try {
if(stmt != null) {
stmt.close();
stmt = null;
}
if(cn != null) {
cn.close();
cn = null;
}

}catch(Exception e) {
System.out.println(e);
}
}
} //这里加上
%>

晕倒 少了个大刮号 呀
  • 打赏
  • 举报
回复
apache-tomcat-5.5.25/work/Catalina/localhost/ota/org/apache/jsp你把这个目录下的文件清空了再试

81,092

社区成员

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

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