kecheng2_0002ejsp_jsp.java
资源名称:JSP02.rar [点击查看]
上传用户:top0756
上传日期:2022-08-11
资源大小:6501k
文件大小:7k
源码类别:
Jsp/Servlet
开发平台:
VBScript
- import java.sql.*;
- import java.util.*;
- import proj112.*;
- import javax.servlet.*;
- import javax.servlet.http.*;
- import javax.servlet.jsp.*;
- import org.apache.jasper.runtime.*;
- public class kecheng2_0002ejsp_jsp extends HttpJspBase {
- // begin [file="/kecheng2.jsp";from=(5,0);to=(5,57)]
- // end
- static {
- }
- public kecheng2_0002ejsp_jsp( ) {
- }
- private static boolean _jspx_inited = false;
- public final void _jspx_init() throws org.apache.jasper.runtime.JspException {
- }
- public void _jspService(HttpServletRequest request, HttpServletResponse response)
- throws java.io.IOException, ServletException {
- JspFactory _jspxFactory = null;
- PageContext pageContext = null;
- HttpSession session = null;
- ServletContext application = null;
- ServletConfig config = null;
- JspWriter out = null;
- Object page = this;
- String _value = null;
- try {
- if (_jspx_inited == false) {
- synchronized (this) {
- if (_jspx_inited == false) {
- _jspx_init();
- _jspx_inited = true;
- }
- }
- }
- _jspxFactory = JspFactory.getDefaultFactory();
- response.setContentType("text/html; charset=GBK");
- pageContext = _jspxFactory.getPageContext(this, request, response,
- "", true, 8192, true);
- application = pageContext.getServletContext();
- config = pageContext.getServletConfig();
- session = pageContext.getSession();
- out = pageContext.getOut();
- // HTML // begin [file="/kecheng2.jsp";from=(0,48);to=(1,0)]
- out.write("rn");
- // end
- // HTML // begin [file="/kecheng2.jsp";from=(1,31);to=(2,0)]
- out.write("rn");
- // end
- // HTML // begin [file="/kecheng2.jsp";from=(2,27);to=(3,0)]
- out.write("rn");
- // end
- // HTML // begin [file="/kecheng2.jsp";from=(3,32);to=(4,0)]
- out.write("rn");
- // end
- // HTML // begin [file="/kecheng2.jsp";from=(4,30);to=(5,0)]
- out.write("rn");
- // end
- // begin [file="/kecheng2.jsp";from=(5,0);to=(5,57)]
- proj112.dbconn a = null;
- boolean _jspx_speciala = false;
- synchronized (pageContext) {
- a= (proj112.dbconn)
- pageContext.getAttribute("a",PageContext.PAGE_SCOPE);
- if ( a == null ) {
- _jspx_speciala = true;
- try {
- a = (proj112.dbconn) java.beans.Beans.instantiate(this.getClass().getClassLoader(), "proj112.dbconn");
- } catch (ClassNotFoundException exc) {
- throw new InstantiationException(exc.getMessage());
- } catch (Exception exc) {
- throw new ServletException (" Cannot create bean of class "+"proj112.dbconn", exc);
- }
- pageContext.setAttribute("a", a, PageContext.PAGE_SCOPE);
- }
- }
- if(_jspx_speciala == true) {
- // end
- // begin [file="/kecheng2.jsp";from=(5,0);to=(5,57)]
- }
- // end
- // HTML // begin [file="/kecheng2.jsp";from=(5,57);to=(14,0)]
- out.write("rn<html>rn<head>rn<title>rnkecheng3rn</title>rn</head>rn<body bgcolor="#ffffff">rnrn");
- // end
- // begin [file="/kecheng2.jsp";from=(14,2);to=(30,4)]
- request.setCharacterEncoding("GBK");
- String kechenghao=request.getParameter("id2");
- String xuehao=(String)session.getAttribute("id");
- String sql="";
- String sql2="";
- String sql3="";
- int totalrecord = 0;
- sql3= "SELECT count(*) as recordcount FROM 选课关联 where stu_id='"+xuehao+"'";
- ResultSet rs = a.executeQuery(sql3);
- if (rs.next()) totalrecord = rs.getInt("recordcount");
- if(totalrecord<3)
- {
- sql="SELECT * FROM 选课关联 where stu_id='"+xuehao+"' and kch='"+kechenghao+"'";
- ResultSet rs1=a.executeQuery(sql);
- if(rs1.next())
- {
- // end
- // HTML // begin [file="/kecheng2.jsp";from=(30,6);to=(34,3)]
- out.write("rn <script language="javascript">rn alert("你已经选了这门课,请重新选择");rn </script>rn ");
- // end
- // begin [file="/kecheng2.jsp";from=(34,5);to=(39,5)]
- }
- else
- {
- sql2=" INSERT INTO 选课关联(stu_id,kch) values('"+xuehao+"','"+kechenghao+"')";
- a.executeUpdate(sql2);
- // end
- // HTML // begin [file="/kecheng2.jsp";from=(39,7);to=(43,5)]
- out.write("rn <script language="javascript">rn alert("选课成功,请继续选课");rn </script>rn ");
- // end
- // begin [file="/kecheng2.jsp";from=(43,7);to=(46,2)]
- }
- }
- else
- {
- // end
- // HTML // begin [file="/kecheng2.jsp";from=(46,4);to=(50,1)]
- out.write("rn <script language="javascript">rn alert("你只能选3门课程,请确认后在选");rn </script>rn ");
- // end
- // begin [file="/kecheng2.jsp";from=(50,3);to=(51,0)]
- }
- // end
- // HTML // begin [file="/kecheng2.jsp";from=(51,2);to=(60,0)]
- out.write("rn <script language="javascript">rn history.go(-1) ;rn </script>rnrnrnrn</body>rn</html>rn");
- // end
- } catch (Throwable t) {
- if (out != null && out.getBufferSize() != 0)
- out.clearBuffer();
- if (pageContext != null) pageContext.handlePageException(t);
- } finally {
- if (_jspxFactory != null) _jspxFactory.releasePageContext(pageContext);
- }
- }
- }