__searchstudent.java

来自「100多M的J2EE培训内容」· Java 代码 · 共 259 行

JAVA
259
字号
/* compiled from JSP: /searchStudent.jsp
*
* This code was automatically generated at 16:29:52 on 2003-8-29
* by weblogic.servlet.jsp.Jsp2Java -- do not edit.
*/

package jsp_servlet;

import java.io.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.jsp.*;
import javax.servlet.jsp.tagext.*;

// User imports
import java.util.ArrayList; //[ /searchStudent.jsp; Line: 3]import java.util.Collection; //[ /searchStudent.jsp; Line: 4]import javax.ejb.ObjectNotFoundException; //[ /searchStudent.jsp; Line: 5]import javax.naming.InitialContext; //[ /searchStudent.jsp; Line: 6]import cmpsample.*; //[ /searchStudent.jsp; Line: 7]

// built-in init parameters:
// boolean             _verbose -- wants debugging

// Well-known variables:
// JspWriter out                  -- to write to the browser
// HttpServletRequest  request    -- the request object.
// HttpServletResponse response   -- the response object.
// PageContext pageContext        -- the page context for this JSP
// HttpSession session            -- the session object for the client (if any)
// ServletContext application     -- The servlet (application) context
// ServletConfig config           -- The ServletConfig for this JSP
// Object page                    -- the instance of this page's implementation class (i.e., 'this')

/**
* This code was automatically generated at 16:29:52 on 2003-8-29
* by weblogic.servlet.jsp.Jsp2Java -- do not edit.
*
* Copyright (c) 2003 by BEA Systems, Inc. All Rights Reserved.
*/
public final class __searchstudent
extends
weblogic.servlet.jsp.JspBase
implements weblogic.servlet.jsp.StaleIndicator
{
  
  // StaleIndicator interface  public boolean _isStale() {    weblogic.servlet.jsp.StaleChecker sci =(weblogic.servlet.jsp.StaleChecker)(getServletConfig().getServletContext());    java.io.File f = null;    long lastModWhenBuilt = 0L;    if (sci.isResourceStale("/searchStudent.jsp", 1055744848000L, "8.1.1.0")) return true;    return false;  }    public static boolean _staticIsStale(weblogic.servlet.jsp.StaleChecker sci) {    java.io.File f = null;    long lastModWhenBuilt = 0L;    if (sci.isResourceStale("/searchStudent.jsp", 1055744848000L, "8.1.1.0")) return true;    return false;  }      private static void _writeText(ServletResponse rsp, JspWriter out, String block, byte[] blockBytes) throws IOException {    if (!_WL_ENCODED_BYTES_OK || _hasEncodingChanged(rsp)) {      out.print(block);    } else {      ((weblogic.servlet.jsp.ByteWriter)out).write(blockBytes, block);    }   }      private static boolean _hasEncodingChanged(ServletResponse rsp) {    if (_WL_ORIGINAL_ENCODING.equals(rsp.getCharacterEncoding())) {      return false;    }    return true;  }    private static boolean _WL_ENCODED_BYTES_OK = true;    private static final String _WL_ORIGINAL_ENCODING = "GBK";    private static byte[] _getBytes(String block) {    try {      return block.getBytes(_WL_ORIGINAL_ENCODING);    } catch (java.io.UnsupportedEncodingException u) {      _WL_ENCODED_BYTES_OK = false;    }    return null;  }  private final static String _wl_block0 = "\r\n\r\n";  private final static byte[] _wl_block0Bytes = _getBytes(_wl_block0);  private final static String _wl_block1 = "\r\n";  private final static byte[] _wl_block1Bytes = _getBytes(_wl_block1);  private final static String _wl_block2 = "\r\n";  private final static byte[] _wl_block2Bytes = _getBytes(_wl_block2);  private final static String _wl_block3 = "\r\n";  private final static byte[] _wl_block3Bytes = _getBytes(_wl_block3);  private final static String _wl_block4 = "\r\n";  private final static byte[] _wl_block4Bytes = _getBytes(_wl_block4);  private final static String _wl_block5 = "\r\n\r\n<html>\r\n<head><title>Chapter 11 CMP 2.0 Sample Example </title></head>\r\n<body bgcolor=\"white\">\r\n<center>\r\n<h2>Chapter 11 CMP 2.0 StudentEJB - Search for a student entity and list courses and addresses</h2>\r\n\r\nSearch for a Student:\r\n<p>\r\n    <form method=\"get\" action=\"/WebApp/searchStudent.jsp\">\r\n    Search by\r\n    <select name=\"searchCriteria\">\r\n      <option value=\"studentID\" selected>Student ID\r\n      <option value=\"lastName\">Last Name\r\n      <option value=\"firstName\">First Name\r\n    </select>\r\n    <input type=\"text\" name=\"searchText\" size=\"25\">\r\n    <p>\r\n    <input type=\"submit\" value=\"Search\">\r\n    </form>\r\n\r\n";  private final static byte[] _wl_block5Bytes = _getBytes(_wl_block5);  private final static String _wl_block6 = "\r\n<hr>\r\n<p>\r\nResults of the search: <p>\r\n";  private final static byte[] _wl_block6Bytes = _getBytes(_wl_block6);  private final static String _wl_block7 = "\r\n<b> ";  private final static byte[] _wl_block7Bytes = _getBytes(_wl_block7);  private final static String _wl_block8 = "  ";  private final static byte[] _wl_block8Bytes = _getBytes(_wl_block8);  private final static String _wl_block9 = " </b> is registered in\r\n";  private final static byte[] _wl_block9Bytes = _getBytes(_wl_block9);  private final static String _wl_block10 = " classes listed below: <p>\r\n\r\n<table border=2>\r\n<tr><th>Roster ID</th> <th>Schedule ID</th></tr>\r\n";  private final static byte[] _wl_block10Bytes = _getBytes(_wl_block10);  private final static String _wl_block11 = "\r\n<tr>\r\n<td> ";  private final static byte[] _wl_block11Bytes = _getBytes(_wl_block11);  private final static String _wl_block12 = " </td>\r\n<td> ";  private final static byte[] _wl_block12Bytes = _getBytes(_wl_block12);  private final static String _wl_block13 = " </td>\r\n</tr>\r\n";  private final static byte[] _wl_block13Bytes = _getBytes(_wl_block13);  private final static String _wl_block14 = "\r\n</table>\r\n<p>\r\n and has\r\n";  private final static byte[] _wl_block14Bytes = _getBytes(_wl_block14);  private final static String _wl_block15 = " addresses<p>\r\n<table border=3>\r\n<tr><th>Strret</th><th>city</th><th>State</th></tr>\r\n";  private final static byte[] _wl_block15Bytes = _getBytes(_wl_block15);  private final static String _wl_block16 = "\r\n<tr>\r\n<td>";  private final static byte[] _wl_block16Bytes = _getBytes(_wl_block16);  private final static String _wl_block17 = "</td>\r\n<td> ";  private final static byte[] _wl_block17Bytes = _getBytes(_wl_block17);  private final static String _wl_block18 = "</td>\r\n<td> ";  private final static byte[] _wl_block18Bytes = _getBytes(_wl_block18);  private final static String _wl_block19 = "</td>\r\n</tr>\r\n";  private final static byte[] _wl_block19Bytes = _getBytes(_wl_block19);  private final static String _wl_block20 = "\r\n</table>\r\n";  private final static byte[] _wl_block20Bytes = _getBytes(_wl_block20);  private final static String _wl_block21 = "\r\n\r\n<hr>\r\n[<a href=\"/WebApp/index.html\">HOME</a>]\r\n</center>\r\n</body>\r\n</html>\r\n";  private final static byte[] _wl_block21Bytes = _getBytes(_wl_block21);  
  
  public void _jspService(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws java.io.IOException, javax.servlet.ServletException 
  {  
    
    // declare and set well-known variables:
    javax.servlet.ServletConfig config = getServletConfig();
    javax.servlet.ServletContext application = config.getServletContext();
    javax.servlet.jsp.tagext.Tag _activeTag = null;
    // variables for Tag extension protocol    
    Object page = this;
    javax.servlet.jsp.JspWriter out;
    javax.servlet.jsp.PageContext pageContext =    javax.servlet.jsp.JspFactory.getDefaultFactory().getPageContext(this, request, response, null, true, 8192, true);    
    response.setHeader("Content-Type", "text/html; charset=GBK");    out = pageContext.getOut();    JspWriter _originalOut = out;    
    javax.servlet.http.HttpSession session = request.getSession(true);    
    
    
    try { // error page try block            response.setContentType("text/html; charset=GBK");            _writeText(response, out, _wl_block0, _wl_block0Bytes);      _writeText(response, out, _wl_block1, _wl_block1Bytes);      _writeText(response, out, _wl_block2, _wl_block2Bytes);      _writeText(response, out, _wl_block3, _wl_block3Bytes);      _writeText(response, out, _wl_block4, _wl_block4Bytes);      _writeText(response, out, _wl_block5, _wl_block5Bytes);      //[ /searchStudent.jsp; Line: 29]      String text = request.getParameter("searchText"); //[ /searchStudent.jsp; Line: 30]      String criteria = request.getParameter("searchCriteria"); //[ /searchStudent.jsp; Line: 31]      //[ /searchStudent.jsp; Line: 32]      if (text != null && !"".equals(text)) { //[ /searchStudent.jsp; Line: 33]        try { //[ /searchStudent.jsp; Line: 34]          InitialContext ic = new InitialContext(); //[ /searchStudent.jsp; Line: 35]          Object obj = ic.lookup("Student"); //[ /searchStudent.jsp; Line: 36]          StudentHome home = (StudentHome) obj; //[ /searchStudent.jsp; Line: 37]          //[ /searchStudent.jsp; Line: 38]          Collection Students = new ArrayList(); //[ /searchStudent.jsp; Line: 39]          if ("studentID".equals(criteria)) { //[ /searchStudent.jsp; Line: 40]            try { //[ /searchStudent.jsp; Line: 41]              Student student = home.findByPrimaryKey(text); //[ /searchStudent.jsp; Line: 42]              Students.add(student); //[ /searchStudent.jsp; Line: 43]            } catch (ObjectNotFoundException ex) {} //[ /searchStudent.jsp; Line: 44]          } //[ /searchStudent.jsp; Line: 45]          else if ("lastName".equals(criteria)) { //[ /searchStudent.jsp; Line: 46]            Students = home.findByLastName(text); //[ /searchStudent.jsp; Line: 47]          } //[ /searchStudent.jsp; Line: 48]          else if ("firstName".equals(criteria)) { //[ /searchStudent.jsp; Line: 49]            Students = home.findByFirstName(text); //[ /searchStudent.jsp; Line: 50]          } //[ /searchStudent.jsp; Line: 51]          else //[ /searchStudent.jsp; Line: 52]          {  } //[ /searchStudent.jsp; Line: 53]          //[ /searchStudent.jsp; Line: 54]          //[ /searchStudent.jsp; Line: 55]          _writeText(response, out, _wl_block6, _wl_block6Bytes);          //[ /searchStudent.jsp; Line: 60]          for (int i = 0; i < Students.size(); i++) { //[ /searchStudent.jsp; Line: 61]            Student stud = (Student)((ArrayList)Students).get(i); //[ /searchStudent.jsp; Line: 62]            String sid = (String) stud.getPrimaryKey(); //[ /searchStudent.jsp; Line: 63]            ArrayList rosterList = stud.getRosterList(); //[ /searchStudent.jsp; Line: 64]            _writeText(response, out, _wl_block7, _wl_block7Bytes);            out.print(String.valueOf(stud.getFirstname()));  //[ /searchStudent.jsp; Line: 66]            _writeText(response, out, _wl_block8, _wl_block8Bytes);            out.print(String.valueOf(stud.getLastname()));  //[ /searchStudent.jsp; Line: 66]            _writeText(response, out, _wl_block9, _wl_block9Bytes);            out.print(String.valueOf(stud.getRosterList().size()));  //[ /searchStudent.jsp; Line: 67]            _writeText(response, out, _wl_block10, _wl_block10Bytes);            //[ /searchStudent.jsp; Line: 71]            for (int j=0; j < rosterList.size(); j++) //[ /searchStudent.jsp; Line: 72]            { //[ /searchStudent.jsp; Line: 73]              Roster rost = (Roster) rosterList.get(j); //[ /searchStudent.jsp; Line: 74]              _writeText(response, out, _wl_block11, _wl_block11Bytes);              out.print(String.valueOf(rost.fetchRosterID()));  //[ /searchStudent.jsp; Line: 77]              _writeText(response, out, _wl_block12, _wl_block12Bytes);              out.print(String.valueOf(rost.fetchScheduleID()));  //[ /searchStudent.jsp; Line: 78]              _writeText(response, out, _wl_block13, _wl_block13Bytes);              //[ /searchStudent.jsp; Line: 80]            } //[ /searchStudent.jsp; Line: 81]            _writeText(response, out, _wl_block14, _wl_block14Bytes);            out.print(String.valueOf(stud.getAddressList().size()));  //[ /searchStudent.jsp; Line: 86]            _writeText(response, out, _wl_block15, _wl_block15Bytes);            ArrayList list = stud.getAddressList(); //[ /searchStudent.jsp; Line: 89]            for (int k=0; k< list.size(); k++) //[ /searchStudent.jsp; Line: 90]            { //[ /searchStudent.jsp; Line: 91]              Address addr = (Address)list.get(k); //[ /searchStudent.jsp; Line: 92]              _writeText(response, out, _wl_block16, _wl_block16Bytes);              out.print(String.valueOf(addr.getStreet()));  //[ /searchStudent.jsp; Line: 95]              _writeText(response, out, _wl_block17, _wl_block17Bytes);              out.print(String.valueOf(addr.getCity()));  //[ /searchStudent.jsp; Line: 96]              _writeText(response, out, _wl_block18, _wl_block18Bytes);              out.print(String.valueOf(addr.getState()));  //[ /searchStudent.jsp; Line: 97]              _writeText(response, out, _wl_block19, _wl_block19Bytes);              //[ /searchStudent.jsp; Line: 99]            } //[ /searchStudent.jsp; Line: 100]            _writeText(response, out, _wl_block20, _wl_block20Bytes);            //[ /searchStudent.jsp; Line: 103]          } //[ /searchStudent.jsp; Line: 104]        } catch(Exception e) { //[ /searchStudent.jsp; Line: 105]          e.printStackTrace(); //[ /searchStudent.jsp; Line: 106]          out.println(e.toString()); //[ /searchStudent.jsp; Line: 107]        } //[ /searchStudent.jsp; Line: 108]      } //[ /searchStudent.jsp; Line: 109]      _writeText(response, out, _wl_block21, _wl_block21Bytes);    } catch (Throwable __ee) {      while (out != null && out != _originalOut) out = pageContext.popBody();      ((weblogic.servlet.jsp.PageContextImpl)pageContext).handlePageException((Throwable)__ee);    }        
    //before final close brace...
  }
  
  
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?