001 package jsp.num;
002
003 import javax.servlet.*;
004 import javax.servlet.http.*;
005 import javax.servlet.jsp.*;
006 import num.NumberGuessBean;
007
008 public final class numguess_jsp extends org.apache.jasper.runtime.HttpJspBase
009 implements org.apache.jasper.runtime.JspSourceDependent {
010
011 private static java.util.List _jspx_dependants;
012
013 public Object getDependants() {
014 return _jspx_dependants;
015 }
016
017 public void _jspService(HttpServletRequest request, HttpServletResponse response)
018 throws java.io.IOException, ServletException {
019
020 JspFactory _jspxFactory = null;
021 PageContext pageContext = null;
022 HttpSession session = null;
023 ServletContext application = null;
024 ServletConfig config = null;
025 JspWriter out = null;
026 Object page = this;
027 JspWriter _jspx_out = null;
028 PageContext _jspx_page_context = null;
029
030
031 try {
032 _jspxFactory = JspFactory.getDefaultFactory();
033 response.setContentType("text/html");
034 pageContext = _jspxFactory.getPageContext(this, request, response,
035 null, true, 8192, true);
036 _jspx_page_context = pageContext;
037 application = pageContext.getServletContext();
038 config = pageContext.getServletConfig();
039 session = pageContext.getSession();
040 out = pageContext.getOut();
041 _jspx_out = out;
042
043 out.write("<!--\n Licensed to the Apache Software Foundation (ASF) under one or more\n contributor license agreements. See the NOTICE file distributed with\n this work for additional information regarding copyright ownership.\n The ASF licenses this file to You under the Apache License, Version 2.0\n (the \"License\"); you may not use this file except in compliance with\n the License. You may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\n Unless required by applicable law or agreed to in writing, software\n distributed under the License is distributed on an \"AS IS\" BASIS,\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n See the License for the specific language governing permissions and\n limitations under the License.\n\n Number Guess Game\n Written by Jason Hunter, CTO, K&A Software\n http://www.servlets.com\n-->\n\n\n\n");
044 num.NumberGuessBean numguess = null;
045 synchronized (session) {
046 numguess = (num.NumberGuessBean) _jspx_page_context.getAttribute("numguess", PageContext.SESSION_SCOPE);
047 if (numguess == null){
048 numguess = new num.NumberGuessBean();
049 _jspx_page_context.setAttribute("numguess", numguess, PageContext.SESSION_SCOPE);
050 }
051 }
052 out.write('\n');
053 org.apache.jasper.runtime.JspRuntimeLibrary.introspect(_jspx_page_context.findAttribute("numguess"), request);
054 out.write("\n\n<html>\n<head><title>Number Guess</title></head>\n<body bgcolor=\"white\">\n<font size=4>\n\n");
055 if (numguess.getSuccess()) {
056 out.write("\n\n Congratulations! You got it.\n And after just ");
057 out.print( numguess.getNumGuesses() );
058 out.write(" tries.<p>\n\n ");
059 numguess.reset();
060 out.write("\n\n Care to <a href=\"numguess.jsp\">try again</a>?\n\n");
061 } else if (numguess.getNumGuesses() == 0) {
062 out.write("\n\n Welcome to the Number Guess game.<p>\n\n I'm thinking of a number between 1 and 100.<p>\n\n <form method=get>\n What's your guess? <input type=text name=guess>\n <input type=submit value=\"Submit\">\n </form>\n\n");
063 } else {
064 out.write("\n\n Good guess, but nope. Try <b>");
065 out.print( numguess.getHint() );
066 out.write("</b>.\n\n You have made ");
067 out.print( numguess.getNumGuesses() );
068 out.write(" guesses.<p>\n\n I'm thinking of a number between 1 and 100.<p>\n\n <form method=get>\n What's your guess? <input type=text name=guess>\n <input type=submit value=\"Submit\">\n </form>\n\n");
069 }
070 out.write("\n\n</font>\n</body>\n</html>\n");
071 } catch (Throwable t) {
072 if (!(t instanceof SkipPageException)){
073 out = _jspx_out;
074 if (out != null && out.getBufferSize() != 0)
075 out.clearBuffer();
076 if (_jspx_page_context != null) _jspx_page_context.handlePageException(t);
077 }
078 } finally {
079 if (_jspxFactory != null) _jspxFactory.releasePageContext(_jspx_page_context);
080 }
081 }
082 }