当我运行以下代码时...我收到一个错误

时间:2013-12-09 18:19:15

标签: mysql jsp java-ee

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org    /TR/html4/loose.dtd">
<%@ page import="java.sql.*" %>
<%@ page import="java.io.*" %>

<HTML>
<HEAD>
    <TITLE>Login </TITLE>
</HEAD>

<BODY bgcolor="#ffffcc">
  <font size="+3" color="red"><br>Welcome !!!!</font>
  <FORM action="" method="get">
    <TABLE style="background-color: #ECE5B6;" WIDTH="30%" >

      <TR>
          <TH width="50%">id</TH>
          <TD width="50%"><INPUT TYPE="text" NAME="id1"></TD>
      </tr>
<TR>
    <TH width="50%">password</TH>
 <TD width="50%"><INPUT TYPE="password" NAME="pass1"></TD>
  </tr>

  <TR>
      <TH></TH>
      <TD width="50%"><INPUT TYPE="submit" VALUE="submit"></TD>
  </tr>
   </TABLE>

<%
   String id = request.getParameter("id1");
   String  pass= request.getParameter("pass1");

   String connectionURL ="jdbc:mysql://localhost/test";
   Connection connection = null;


   Class.forName("com.mysql.jdbc.Driver").newInstance();
   int updateQuery = 0;
   if(id!=null && pass!=null){
   if(id!="" && pass!="" ){
   try {
       connection = DriverManager.getConnection(connectionURL,"root","dhawanbhai1");

   Statement st=connection.createStatement();
   ResultSet rs=st.executeQuery("select id,password from userpass");  
      while(rs.next())  
           {  
           String username=rs.getString(1);  
           String password=rs.getString(2);  
           if(id.equals(username) && pass.equals(password)){  
               session.setAttribute("username",id);  
               response.sendRedirect("http://localhost:8081/LoginExample/Welcome.jsp");  
           }  
                   else{  
               response.sendRedirect("http://localhost:8081/LoginExample/LoginError.jsp");  
                   }  
       }  
  }            
                   catch (Exception ex) {
       out.println("Unable to connect to database.");
       }
       finally {
           pstatement.close();
           connection.close();
            }


%>
  </FORM>
 </body> 
</html>

错误: HTTP状态500 - 无法为JSP编译类:


输入异常报告 message无法为JSP编译类: description服务器遇到内部错误,导致无法完成此请求。 例外 org.apache.jasper.JasperException:无法为JSP编译类:

生成的java文件中的行:[40]发生错误:[C:\ Users \ jabaraku \ workspace.metadata.plugins \ org.eclipse.wst.server.core \ tmp0 \ work \ Catalina \ localhost \ LoginExample \组织\阿帕奇\ JSP \ LoginPage_jsp.java] 语法错误,插入“}”以完成ClassBody

生成的java文件中的行:[149]发生错误:[C:\ Users \ jabaraku \ workspace.metadata.plugins \ org.eclipse.wst.server.core \ tmp0 \ work \ Catalina \ localhost \ LoginExample \组织\阿帕奇\ JSP \ LoginPage_jsp.java] 语法错误,插入“else语句”以完成IfStatement

生成的java文件中的行:[149]发生错误:[C:\ Users \ jabaraku \ workspace.metadata.plugins \ org.eclipse.wst.server.core \ tmp0 \ work \ Catalina \ localhost \ LoginExample \组织\阿帕奇\ JSP \ LoginPage_jsp.java] 语法错误,插入“}”以完成阻止

生成的java文件中的行:[149]发生错误:[C:\ Users \ jabaraku \ workspace.metadata.plugins \ org.eclipse.wst.server.core \ tmp0 \ work \ Catalina \ localhost \ LoginExample \组织\阿帕奇\ JSP \ LoginPage_jsp.java] 语法错误,插入“else语句”以完成IfStatement

生成的java文件中的行:[149]发生错误:[C:\ Users \ jabaraku \ workspace.metadata.plugins \ org.eclipse.wst.server.core \ tmp0 \ work \ Catalina \ localhost \ LoginExample \组织\阿帕奇\ JSP \ LoginPage_jsp.java] 语法错误,插入“}”以完成阻止

生成的java文件中的行:[161]发生错误:[C:\ Users \ jabaraku \ workspace.metadata.plugins \ org.eclipse.wst.server.core \ tmp0 \ work \ Catalina \ localhost \ LoginExample \组织\阿帕奇\ JSP \ LoginPage_jsp.java] 令牌“}”上的语法错误,删除此令牌

堆栈跟踪:     org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:103)     org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:366)     org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:468)     org.apache.jasper.compiler.Compiler.compile(Compiler.java:378)     org.apache.jasper.compiler.Compiler.compile(Compiler.java:353)     org.apache.jasper.compiler.Compiler.compile(Compiler.java:340)     org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:646)     org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:357)     org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)     org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)     javax.servlet.http.HttpServlet.service(HttpServlet.java:728)     org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51) note备注根本原因的完整堆栈跟踪可在Apache Tomcat /7.0.47日志。

中找到

Apache Tomcat / 7.0.47

2 个答案:

答案 0 :(得分:0)

最后你应该} ,请检查。

答案 1 :(得分:0)

查看错误输出。您不要关闭代码中的if语句。在}声明之后,您应该有两个finally