<code><html>
<head>
<title>Insert title here</title>
</head>
<body>
<%@page import="java.io.*"%>
<%@page import="java.sql.*"%>
<%@page import="java.util.*,java.sql.*,java.io.*"%>
<%
Connection conn= null;
//Statement stmt= null;
Statement stmt2= null;
ResultSet rs=null;
int sno=0,c=0;
String tsno;
int cform=0;
String fc=(String)session.getAttribute("fclass");
String fy=(String)session.getAttribute("fyear");
//String srno=(String)hs.getValue("srlno");
String sid1=(String)session.getAttribute("sid");
String spwd1=(String)session.getAttribute("spwd");
//String shat2=(String)hs.getValue("shat");
System.out.println("update = "+sid1);
// System.out.println("update = "+spwd);
// System.out.println("update = "+shat2);
sno=c;
int shat=0;
if( sid1==null || spwd1==null || sno==0)
{
sid1 = request.getParameter("tsid2");
System.out.println(sid1);
spwd1= request.getParameter("tspwd2");
fc = request.getParameter("tclass");
fy = request.getParameter("tyear");
tsno = request.getParameter("tc");
sno=Integer.parseInt(tsno);
}
int i=0, k=0;
// Previous Form
String ht02="g2",ht03="g3",ht04="g4",ht05="g5",ht06="g6",ht07="g7",ht08="g8",ht09="g9";//,ht10="g10",ht11="g11",ht12="g12",ht13="g13";
// New form
String ft2,ft3,ft4,ft5,ft6,ft7,ft8,ft9;//ft10,ft11,ft12,ft13;
int gt4,gt5,gt6,gt7,gt8,gt9;//,gt10,gt11,gt12,gt13;
String fs=new String("y");
int up=0;
//------------------------------------------------------------------------------
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
conn=DriverManager.getConnection("jdbc:odbc:aec","Vinayaka","Vinayaka");
stmt2=conn.createStatement();
String Sq="select *From STUDENTS_INFO where STUDENTID='"+sid1+"' and PWD='"+spwd1+"' ";
rs = stmt2.executeQuery(Sq);
while(rs.next())
{
if (fs.equals(rs.getString("FORMSUBMITT")))
{
System.out.println(" Status in get"+fs);
up=1;
response.sendRedirect("errorpage.html");
}
}
}
catch(Exception e2){
e2.printStackTrace();}
//-----------------------------------------------------------------------------
if (up==0 && sid1!=null)
{
while (k<sno)
{ System.out.println("This loop in"+i+"times"+" "+sid1);
ht02="ht02+i"; ht03=ht03+i; ht04=ht04+i; ht05=ht05+i; ht06=ht06+i;
ht07=ht07+i; ht08=ht08+i; ht09=ht09+i;// ht10=ht10+i; ht11=ht11+i; ht12=ht12+i; ht13=ht13+i;
ft2 = request.getParameter(ht02); ft3 = request.getParameter(ht03); ft4 = request.getParameter(ht04);
ft5 = request.getParameter(ht05); ft6 = request.getParameter(ht06); ft7 = request.getParameter(ht07);
ft8 = request.getParameter(ht08); ft9 = request.getParameter(ht09); /*ft10 = req.getParameter(ht10);
ft11 = req.getParameter(ht11);ft12 = req.getParameter(ht12);ft13 = req.getParameter(ht13);*/
gt4=Integer.parseInt(ft4); gt5=Integer.parseInt(ft5); gt6=Integer.parseInt(ft6);
gt7=Integer.parseInt(ft7); gt8=Integer.parseInt(ft8); gt9=Integer.parseInt(ft9);
/*gt10=Integer.parseInt(ft10); gt11=Integer.parseInt(ft11); gt12=Integer.parseInt(ft12);
gt13=Integer.parseInt(ft13);*/
float tot=((float)(gt4+gt5+gt6+gt7+gt8+gt9))/6;
try
{
stmt2=conn.createStatement();
stmt2.executeUpdate( "Insert into SUB_DET values("+i+",'"+ft3+"','"+ft2+"','"+fc+"','"+fy+"',"+gt4+","+gt5+","+gt6+","+gt7+","+gt8+","+gt9+","+tot+")");
response.sendRedirect("logout.html");
}
catch(Exception e){
e.printStackTrace();}
i=i+1;
}
try
{
stmt2.executeUpdate("update STUDENTS_INFO set formsubmitt='"+fs+"' where STUDENTID='"+sid1+"' and pwd='"+spwd1+"' ");
cform=1;
}
catch(Exception e1){
e1.printStackTrace();}
/*try
{
if(sid!=null)
{
stmt2=conn.createStatement();
stmt2.executeUpdate("update STUDENTS_INFO set formsubmitt='"+fs+"' where STUDENTID='"+sid+"' and pwd='"+spwd+"' ");
}
}
catch(Exception e){
e.printStackTrace();}*/
if(rs!=null)
{
rs.close();
System.out.println("Feed back rs is Closed");
}
if(stmt2!=null)
{
stmt2.close();
System.out.println("Feed back statement is Closed");
}
if(conn!=null)
{
conn.close();
System.out.println("Feed back update Connection2 Closed");
}
}
}
finally
{
System.out.println("tinku");
}
%>
</body>
</html>
</code>
这是错误:
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: Unable to compile class for JSP:
An error occurred at line: 229 in the generated java file
Syntax error on token "catch", Identifier expected
An error occurred at line: 231 in the generated java file
out cannot be resolved
An error occurred at line: 231 in the generated java file
_jspx_out cannot be resolved
An error occurred at line: 232 in the generated java file
out cannot be resolved
An error occurred at line: 232 in the generated java file
out cannot be resolved
An error occurred at line: 233 in the generated java file
out cannot be resolved
An error occurred at line: 234 in the generated java file
_jspx_page_context cannot be resolved
An error occurred at line: 234 in the generated java file
_jspx_page_context cannot be resolved
An error occurred at line: 236 in the generated java file
Syntax error on token "finally", { expected
An error occurred at line: 237 in the generated java file
_jspx_page_context cannot be resolved
Stacktrace:
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:92)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330)
org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:439)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:349)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:327)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:314)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:592)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:326)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
答案 0 :(得分:1)
评论finally
{
System.out.println("tinku");
}
它会起作用
答案 1 :(得分:1)
这正是Java代码不应该放在JSP中的原因。将servlet用于Java代码,并且仅在JSP中使用EL,JSTL和其他JSP标记,其唯一目的应该是生成HTML标记。
当Java代码在servlet中时,它是预编译的,并且IDE可帮助您识别和修复编译问题。 IDE还将帮助您格式化和缩进Java代码,以使其可读。