运行时出错:
illegal start of type
> expected
"regist.jsp": 'try' without 'catch' or 'finally'
"regist.jsp": <identifier> expected
"regist.jsp": 'class' or 'interface' expected
"regist.jsp": 'class' or 'interface' expected
"regist.jsp": 'class' or 'interface' expected at line 0代码
comm.jsp
<%@page import="java.util.*"%>
<%@ page session="true" %>
<%@include file="head.htm"%>
<%@page import="java.sql.*,java.lang.Double.*"%>
<%@page import="java.io.*"%>
<%
try{
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
}
catch(ClassNotFoundException e){}
String url="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=WebStore";
String id="sa";
String password="guo";
try{
Connection conn= DriverManager.getConnection(url,id,password); CallableStatement cstmt=null;
ResultSet rs = null;
}catch(SQLException ee){}
String strSql;
String user;
String sysuser;
String sysuserType;
String action;%>
regist.jsp
<%@ page contentType="text/html;charset=gb2312"%>
<%@page import="java.util.*"%>
<%@page import="java.io.*"%>
<%@page import="java.sql.*,java.lang.Double.*"%>
<%@include file="comm.jsp"%><HTML>
<head>
<title>注册</title>
</head>
<body bgcolor="#FFFFFF" text="#000000"><div>
<%
String customerID=request.getParameter("CustomerID").trim();
String customerName=request.getParameter("CustomerName").trim();
String pwd=request.getParameter("password");
String repwd=request.getParameter("repassword");
String idCard=request.getParameter("IDCard");
String address=request.getParameter("address").trim();
String province=request.getParameter("Province");
String zipCode=request.getParameter("zipcode");
String phone=request.getParameter("phone");strSql = "{call dbo.sp_insertcustomer(?,?,?,?,?,?,?,?,?)}";
cstmt = conn.prepareCall(strSql);
// Register the Output Parameter
cstmt.registerOutParameter(9, java.sql.Types.INTEGER);
//Set Input Parameters
cstmt.setString(1,customerID);
cstmt.setString(2,customerName);
cstmt.setString(3,pwd);
cstmt.setString(4,idCard);
cstmt.setString(5,address);
cstmt.setString(6,province);
cstmt.setString(7,zipCode);
cstmt.setString(8,phone); cstmt.executeUpdate();
int iR=cstmt.getInt(9);
if(iR==0)
{
session.putValue("user",customerID);
%>
<jsp:forward page="CustomerInfo.jsp?action=view"/>
<%
}
else if(iR==1)
{
%>
<jsp:forward page="regist.htm"/>
<%
} rs.close();
cstmt.close();
conn.close();%>
</div>
</body>
</HTML>
illegal start of type
> expected
"regist.jsp": 'try' without 'catch' or 'finally'
"regist.jsp": <identifier> expected
"regist.jsp": 'class' or 'interface' expected
"regist.jsp": 'class' or 'interface' expected
"regist.jsp": 'class' or 'interface' expected at line 0代码
comm.jsp
<%@page import="java.util.*"%>
<%@ page session="true" %>
<%@include file="head.htm"%>
<%@page import="java.sql.*,java.lang.Double.*"%>
<%@page import="java.io.*"%>
<%
try{
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
}
catch(ClassNotFoundException e){}
String url="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=WebStore";
String id="sa";
String password="guo";
try{
Connection conn= DriverManager.getConnection(url,id,password); CallableStatement cstmt=null;
ResultSet rs = null;
}catch(SQLException ee){}
String strSql;
String user;
String sysuser;
String sysuserType;
String action;%>
regist.jsp
<%@ page contentType="text/html;charset=gb2312"%>
<%@page import="java.util.*"%>
<%@page import="java.io.*"%>
<%@page import="java.sql.*,java.lang.Double.*"%>
<%@include file="comm.jsp"%><HTML>
<head>
<title>注册</title>
</head>
<body bgcolor="#FFFFFF" text="#000000"><div>
<%
String customerID=request.getParameter("CustomerID").trim();
String customerName=request.getParameter("CustomerName").trim();
String pwd=request.getParameter("password");
String repwd=request.getParameter("repassword");
String idCard=request.getParameter("IDCard");
String address=request.getParameter("address").trim();
String province=request.getParameter("Province");
String zipCode=request.getParameter("zipcode");
String phone=request.getParameter("phone");strSql = "{call dbo.sp_insertcustomer(?,?,?,?,?,?,?,?,?)}";
cstmt = conn.prepareCall(strSql);
// Register the Output Parameter
cstmt.registerOutParameter(9, java.sql.Types.INTEGER);
//Set Input Parameters
cstmt.setString(1,customerID);
cstmt.setString(2,customerName);
cstmt.setString(3,pwd);
cstmt.setString(4,idCard);
cstmt.setString(5,address);
cstmt.setString(6,province);
cstmt.setString(7,zipCode);
cstmt.setString(8,phone); cstmt.executeUpdate();
int iR=cstmt.getInt(9);
if(iR==0)
{
session.putValue("user",customerID);
%>
<jsp:forward page="CustomerInfo.jsp?action=view"/>
<%
}
else if(iR==1)
{
%>
<jsp:forward page="regist.htm"/>
<%
} rs.close();
cstmt.close();
conn.close();%>
</div>
</body>
</HTML>
解决方案 »
- struts2找不到action
- 页面集成,B的session覆盖掉了A系统的session
- 难!超难!!如何关闭cgi做的系统??除了用页面直接访问
- tomcat里面部署多个网站,不同的网站用不同的端口
- 关于Servlet输出中文问题
- Servlet如何运行
- jsp中如何把String写入oracle数据库的clob字段中
- 请教三态树型结构
- 请求Apache+Tomcat+ApacheModuleJServ.dll的详细下载地址和安装方法
- 对Servlet的一些疑惑,请求解答!!!!!!!!!!!!!
- 简单问题: 做了一个简单的strust例子, 在jbuilder里可以运行, 如何把它放到tomcat下,通过IE可以打开?
- jsp与InputStream 问题
..乱
"regist.jsp": 'try' without 'catch' or 'finally'
cstmt.close();
conn.close();会抛出异常
"regist.jsp": 'try' without 'catch' or 'finally' //????????不解
if(conn!=null) conn.close();
}catch(SQLException e){
e.printStackTrace(System.out);
}
以上代码放在finally里面,以确保conn正确关闭