home | class notes | homework | jsp help | mysql help
Binary Search Guessing Game: Here are the JSP sources from the in-class demo in one text file: guessing-game.jsp.txt.
If you want to play the game, knock yourself out.
See the second part of this page for the files from the live demonstration in class 4/20.
https://tools.cs.uchicago.edu/activate_cgi_serviceWhen you register, be sure to check the button labeled "CMSC Servlets/JSP".
https://tomcat-cmsc.cs.uchicago.edu/tomcat-manager/pwd/pwd.cgiThis may or may not take you to the Tomcat Manager page. If so, leave the browser open there.
/stage/tomcat-cmsc/yournameNavigate to that folder. Create a directory called webapps inside your tomcat-cmsc folder, i.e.,
/stage/tomcat-cmsc/yourname/webappsFurthermore, create
/stage/tomcat-cmsc/yourname/webapps/index.html
/stage/tomcat-cmsc/yourname/webapps/JSPTest/test.jsp
<p> <a href="JSPTest/test.jsp">Link to JSP test.</a> </p>- Put this text in JSPTest/test.jsp:
<p> This should be 4: <%= 5-1 %>. </p>- Log in to the Tomcat Manager if you aren't already logged in:
https://tomcat-cmsc.cs.uchicago.edu/tomcat-manager/man/manager.cgiIn the box labeled Context Path, type/yournameIn the box below and to the left of that, labeled "Directory containing WEB-INF/", type/yourname/webappsClick the "Install" button.- Hopefully, that did the trick. You should see your username in the list of running webapps. Click and see if your jsp test is working. You will be able to visit and link to your webapps at the following URL:
http://tomcat-cmsc.cs.uchicago.edu:8180/yourname/
Thanks to Josh Zenker, whose files I pilfered. Don't do what I did, people!
<form method=POST action=greet.jsp> <p> Please enter your name: <input type=text name="name"> </p> <p> <select name=bgc> <option value="#FF0000">Red</option> <option value="#00FF00">Green</option> <option value="#FFFFFF">White</option> </select> </p> <input type=submit value="CLICK WHEN READY"> </form> |
<%! class Greeter { private String name; public Greeter(String name) { this.name = name; } public String toHTML() { return "<p>Hello, " + name + "!</p>"; } } %> <% // gather form information String name = request.getParameter("name"); String bgc = request.getParameter("bgc"); Greeter g = new Greeter(name); %> <html> <head></head> <body bgcolor=<%= bgc %> > <h1>Welcome</h1> <%= g.toHTML() %> <h1><%= bgc %></h1> </body> </html> |