home *** CD-ROM | disk | FTP | other *** search
/ PC Professionell 2004 December / PCpro_2004_12.ISO / files / webserver / xampp / xampp-tomcat-addon-1.4.9-installer.exe / colrs_jsp.class (.txt) < prev    next >
Encoding:
Java Class File  |  2004-05-17  |  4.8 KB  |  103 lines

  1. package org.apache.jsp.colors;
  2.  
  3. import colors.ColorGameBean;
  4. import java.io.IOException;
  5. import java.util.List;
  6. import java.util.Vector;
  7. import javax.servlet.ServletConfig;
  8. import javax.servlet.ServletContext;
  9. import javax.servlet.ServletException;
  10. import javax.servlet.http.HttpServletRequest;
  11. import javax.servlet.http.HttpServletResponse;
  12. import javax.servlet.http.HttpSession;
  13. import javax.servlet.jsp.JspFactory;
  14. import javax.servlet.jsp.JspWriter;
  15. import javax.servlet.jsp.PageContext;
  16. import javax.servlet.jsp.SkipPageException;
  17. import org.apache.jasper.runtime.HttpJspBase;
  18. import org.apache.jasper.runtime.JspRuntimeLibrary;
  19. import org.apache.jasper.runtime.JspSourceDependent;
  20.  
  21. public final class colrs_jsp extends HttpJspBase implements JspSourceDependent {
  22.    private static Vector _jspx_dependants;
  23.  
  24.    public List getDependants() {
  25.       return _jspx_dependants;
  26.    }
  27.  
  28.    public void _jspService(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
  29.       JspFactory _jspxFactory = null;
  30.       PageContext pageContext = null;
  31.       HttpSession session = null;
  32.       ServletContext application = null;
  33.       ServletConfig config = null;
  34.       JspWriter out = null;
  35.       JspWriter _jspx_out = null;
  36.       PageContext _jspx_page_context = null;
  37.  
  38.       try {
  39.          _jspxFactory = JspFactory.getDefaultFactory();
  40.          response.setContentType("text/html");
  41.          pageContext = _jspxFactory.getPageContext(this, request, response, (String)null, true, 8192, true);
  42.          _jspx_page_context = pageContext;
  43.          application = pageContext.getServletContext();
  44.          config = pageContext.getServletConfig();
  45.          session = pageContext.getSession();
  46.          out = pageContext.getOut();
  47.          out.write("<html>\r\n<!--\r\n  Copyright 2004 The Apache Software Foundation\r\n\r\n  Licensed under the Apache License, Version 2.0 (the \"License\");\r\n  you may not use this file except in compliance with the License.\r\n  You may obtain a copy of the License at\r\n\r\n      http://www.apache.org/licenses/LICENSE-2.0\r\n\r\n  Unless required by applicable law or agreed to in writing, software\r\n  distributed under the License is distributed on an \"AS IS\" BASIS,\r\n  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n  See the License for the specific language governing permissions and\r\n  limitations under the License.\r\n-->\r\n\r\n");
  48.          ColorGameBean cb = null;
  49.          synchronized(session) {
  50.             cb = (ColorGameBean)_jspx_page_context.getAttribute("cb", 3);
  51.             if (cb == null) {
  52.                cb = new ColorGameBean();
  53.                _jspx_page_context.setAttribute("cb", cb, 3);
  54.             }
  55.          }
  56.  
  57.          out.write(13);
  58.          out.write(10);
  59.          JspRuntimeLibrary.introspect(pageContext.findAttribute("cb"), request);
  60.          out.write("\r\n\r\n");
  61.          cb.processRequest(request);
  62.          out.write("\r\n\r\n<body bgcolor=");
  63.          out.print(cb.getColor1());
  64.          out.write(">\r\n<font size=6 color=");
  65.          out.print(cb.getColor2());
  66.          out.write(">\r\n<p>\r\n\r\n");
  67.          if (cb.getHint()) {
  68.             out.write("\r\n\t\r\n\t<p> Hint #1: Vampires prey at night!\r\n\t<p>  <p> Hint #2: Nancy without the n.\r\n\r\n");
  69.          }
  70.  
  71.          out.write("\r\n\r\n");
  72.          if (cb.getSuccess()) {
  73.             out.write("\r\n\r\n    <p> CONGRATULATIONS!!\r\n\t");
  74.             if (cb.getHintTaken()) {
  75.                out.write("\r\n    \r\n        <p> ( although I know you cheated and peeked into the hints)\r\n\r\n\t");
  76.             }
  77.  
  78.             out.write("\r\n\r\n");
  79.          }
  80.  
  81.          out.write("\r\n\r\n<p> Total attempts so far: ");
  82.          out.print(cb.getAttempts());
  83.          out.write("\r\n<p>\r\n\r\n<p>\r\n\r\n<form method=POST action=colrs.jsp>\r\n\r\nColor #1: <input type=text name= color1 size=16>\r\n\r\n<br>\r\n\r\nColor #2: <input type=text name= color2 size=16>\r\n\r\n<p>\r\n\r\n<input type=submit name=action value=\"Submit\">\r\n<input type=submit name=action value=\"Hint\">\r\n\r\n</form>\r\n\r\n</font>\r\n</body>\r\n</html>\r\n");
  84.       } catch (Throwable t) {
  85.          if (!(t instanceof SkipPageException)) {
  86.             if (_jspx_out != null && _jspx_out.getBufferSize() != 0) {
  87.                _jspx_out.clearBuffer();
  88.             }
  89.  
  90.             if (_jspx_page_context != null) {
  91.                _jspx_page_context.handlePageException(t);
  92.             }
  93.          }
  94.       } finally {
  95.          if (_jspxFactory != null) {
  96.             _jspxFactory.releasePageContext(_jspx_page_context);
  97.          }
  98.  
  99.       }
  100.  
  101.    }
  102. }
  103.