java org.apache.jasper.JasperException: PWC6033: JSP 的 Javac 编译错误

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10189344/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-30 23:59:49  来源:igfitidea点击:

org.apache.jasper.JasperException: PWC6033: Error in Javac compilation for JSP

javajspglassfishnetbeans-7

提问by ksa

unable to compile jsp in netbeans with glass fish server3.1.2,it is showing the following exception

无法在netbeans中用glassfish server3.1.2编译jsp,显示如下异常

org.apache.jasper.JasperException: PWC6033: Error in Javac compilation for JSP

PWC6197: An error occurred at line: 9 in the jsp file: /index.jsp
PWC6199: Generated servlet error:
';' expected

PWC6197: An error occurred at line: 9 in the jsp file: /index.jsp
PWC6199: Generated servlet error:
';' expected

PWC6197: An error occurred at line: 9 in the jsp file: /index.jsp
PWC6199: Generated servlet error:
not a statement

PWC6197: An error occurred at line: 9 in the jsp file: /index.jsp
PWC6199: Generated servlet error:
';' expected

my java and jsp code

我的 java 和 jsp 代码

<%@page contentType="text/html" pageEncoding="UTF-8" %>
<%@page language="java" import= "java.sql.*"%>
<%
String driver="org.postgresql.Driver";
Class.forName(driver).newInstance();
Connection con=null;
ResultSet rst=null;
Statement stmt=null;
try
{
  String url="jdbc:postgresql://localhost:5432/ksa?user="postgres"password="postgres"";
  con=DriverManager.getConnection("url");
  stmt=con.createStatement();
}          
catch(Exception e)
               {
  System.out.println(e.getMessage());
       }
if(request.getParameter("action")!=null)
       {
           String name=request.getParameter("name");
           String address=request.getParameter("address");
           String id=request.getParameter("id");
           stmt.executeUpdate("insert into cd values('"+ name +"','"+ address +"')");
           rst=stmt.executeQuery("select * from cd");             
       }    
%>

netbeans shows the error in the line

netbeans 显示该行中的错误

String url="jdbc:postgresql://localhost:5432/ksa?user="postgres"password="postgres"";

iam using postgresql9.1,the glassfish log shows the following

我使用 postgresql9.1,glassfish 日志显示如下

SEVERE: Error compiling file: /home/adapco/.netbeans/7.1.1/config/GF3_1/domain1  /generated/jsp/cddata/org/apache/jsp/index_jsp.java
WARNING: StandardWrapperValve[jsp]: PWC1406: Servlet.service() for servlet jsp threw exception

采纳答案by Christian Kuetbach

That line is incorrect:

该行不正确:

String url="jdbc:postgresql://localhost:5432/ksa?user="postgres"password="postgres";

It should be:

它应该是:

String url="jdbc:postgresql://localhost:5432/ksa?user=\"postgres\"&password=\"postgres\"";

Update:

更新:

By the way:

顺便一提:

con=DriverManager.getConnection("url");

should be:

应该:

con=DriverManager.getConnection(url);

回答by user8113299

I think it's a small wrong,your '{' and '}' don't match,and i met the same question.

我认为这是一个小错误,你的 '{' 和 '}' 不匹配,我遇到了同样的问题。