Kris' JSP Exercises 1

Last Update: 17 May 2006

Kris' Java Diary
COBOL to Java: Tips and hints for learning Java
Kris' Java Exercises
>Kris' JSP Exercises
CIST2535 Class Homework
[Bottom]

Note: Sourcecode is not available. It's doubtful that I'll ever get around to posting it.

  1. Display the current date and time: DateTime.jsp
  2. Calculate the sine of several angles and display the results: MyFirstJSP.jsp
  3. Display Powers of 2: PowersOf2.jsp
  4. Example Forms (GET and POST - this is HTML, not JSP): ExampleForms.html
    Note: each "submit" button calls "SomeJSP.jsp" which does not exist so an Apache Tomcat error page displays.
    Note: this form replaces the password entered with ***s. Update some of the examples below to do the same thing.
  5. An Order Form: OrderForm.jsp
  6. Simple Book Table: SimpleBookTable.jsp
    Note: this is supposed to retrieve data from a database, but I don't have one set up so I hard-coded some tabled data to display.
    Note to self: this is very much like what I'd want for my own page. Cool!!
  7. A JSP that includes the output of two other JSPs: IncludeActionExample.jsp
  8. A JSP that includes the output of two other HTML: IncludeHTML.jsp
    Note: the "<%@ include file="relative url " flush="true">" command only found the HTML files if I put them in the same directory as the .jsp. I think this is because the command requires a relative url.
  9. Calculate Fibonacci numbers: FibonacciComputation.jsp
  10. Calculate Factorials: FactorialComputation.jsp
  11. Forward request to one of two JSPs based on a random number: ForwardActionExample.jsp
  12. Declare variables and methods (no output): declarations.jsp
  13. Use the "if" statement: decisions.jsp
  14. Use a "for" loop: iteration.jsp
  15. Initialize variables with constants: initializingVariables.jsp
  16. Initialize variables with other variables: initVarWithOtherVar.jsp
  17. Declare arrays: declaringArrays.jsp
  18. Declare a vector: declaringVectors.jsp
  19. Use a vector: usingEnumerations.jsp
  20. Verify login password (does not run alone because it needs HTML member for input/output): login.jsp
  21. HTML code which creates a simple login page (uses login.jsp): login.html
  22. An overloaded method (no output): overloading1.jsp
  23. An overloaded method - overloader calls overloaded (no output): overloading2.jsp
  24. Reference a variable to print out its contents: referencingVariables.jsp
  25. Use a JavaBean that overrides the toString() method: overridingToString.jsp
  26. Call a local method: callingLocalMethods.jsp [source]
  27. Call methods of a JavaBean: callingJavaBeanMethods.jsp [source]
  28. Use the "if" statement (again?): ifStatement.jsp
  29. Use the "if/else" statement (again?): ifElseStatement.jsp
  30. Use the "if/else/if" statement: ifElseIfStatement.jsp
  31. Use the "switch" statement: switchStatement.jsp
  32. Use the "loop" statement to display a checkout order: checkoutOrder.jsp [source]
  33. Use the "while" statement to search for an item in an inventory array: searchingWithWhile.jsp
  34. Use the "continue" statement to print the odd numbers between 0 and 20: continueStatement.jsp
  35. Quicksort with do/while loop: sortingWithDoWhile.jsp
  36. Use Path Related Request Methods: pathInformation.jsp
  37. Use Machine Related Request Methods: machineInformation.jsp
  38. HTML link which passes parameters to a JSP (myFlag.jsp): myFlag.html
  39. HTML link which uses a "form" to pass parameters to a JSP (simpleForm.jsp): simpleForm.html
  40. HTML link which uses a "form" to pass parameters to a JSP (creditCardForm.jsp): creditCardForm.html
  41. Dynamically generate titles: dynamicTitles.jsp
  42. Dynamically generate table: dynamicTable.jsp
  43. Dynamically generate credit card form: dynamicForm.jsp
  44. Configurable Home Page: configurablePage.jsp
    Note: the "<jsp:include page="relative url " flush="true">" command only found the HTML files if I put them in the same directory as the .jsp. I think this is because the command requires a relative url.

    Note: there is a weird text box which displays above the "This is the content" cell of the table. I think it has something to do with a linebreak somewhere in my HTML code for the table, but I can't get rid of it.
  45. Example of using cookies: preferences.jsp
  46. Save the session ID in a cookie. Pass information back and forth between two pages using the session: cds.jsp [source] and toys.jsp [source]
  47. Save the session ID in the URL in case the user has disabled cookies: encodingURLs.jsp
  48. Print all initialization parameters: printAllParmeters.jsp
  49. Throw a customized exception from a JSP: raisingExceptionInJSP.jsp
  50. Throw, then catch, a customized exception from a JSP: raisingAndCatchingExcpInJSP.jsp
  51. Catch an exception thrown by a JavaBean: raisingExceptionInClass.jsp
  52. Gather login information, then ship it to either goodLogin.jsp or badLogin.jsp: login2.jsp
  53. Gather login information, then ship it to either goodLogin3.jsp or badLoginWithExceptionObject.jsp: login3.jsp
  54. Use "plugin" action tag to insert an applet: SimpleApplet.jsp THIS DOES NOT WORK!!
    Note: I can't seem to get applets to run. Dunno if they work at all - is the problem in my browser? Did I upload the applets incorrectly? Or does my webhost need to do some additional setup for my account??
  55. Use Javabeans to generate a random payroll with random info: randomPayroll.jsp
  56. Shopping Cart using a JavaBean: cds2.jsp and toys2.jsp
  57. Use Javabeans to generate a random payroll with random info; set and get JavaBean properties: setAndGetProperties.jsp
  58. Use a Form and a JavaBean: forms.jsp
  59. Include text from another HTML file: IncludeTextExample.jsp
  60. Use the "include" action. Display some combination of two JSP pages, depending on user input: DataSelection.html
  61. Use the "forward" action. Get information from user (does *not* include database update, even though the example in the book does): InputGolferStats.html

My Own Projects

  1. Take form input, generate an email. Using HTML only: mailForm.html
    Note: The user's browser needs to be set up to allow it to submit an e-mailed form. This may require that the user have SMTP based e-mail, and probably won't work if they only have web-based e-mail.
  2. Send email from JSP: email.jsp
    Note: This sends an email with hardcoded text, with a blank screen that comes back once the email is sent.
  3. Send email from HTML Form (calls JSP emailForm.jsp): mailForm2.html
  4. Write text to a flat file: writeFile.jsp
  5. Read text from a flat file: readFile.jsp
  6. Dynamically generate web pages from an array of photos and descriptions: kquilt.jsp
  7. Test new JSP directories: kjava_jsp_ex, kmovie_jsp.
  8. Write a serialized object to a flat file: writeFileSer.jsp
  9. Read a serialized object from a flat file: readFileSer.jsp
  10. Books that I'd like to read: kread_0like.jsp
  11. Read and display database using a JSP: kread_dbBookTest01.jsp
  12. Read and display books from a database using a JSP - more nicely formatted: kread_dbBookTest02.jsp
  13. Read and display books that I HAVE NOT READ from a database using a JSP: kread_dbBookTest03.jsp
  14. Read and display books that I HAVE READ from a database using a JSP: kread_dbBookTest04.jsp
  15. HTML form to select and delete book(s) from database using a JSP & a JavaBean: kread_dbBookTest05.jsp
  16. HTML form to enter and insert a book into a database using a JSP: kread_dbBookTest06.jsp
  17. HTML form to access books from a database using a JSP & a JavaBean: kread_dbBookTest07.jsp
  18. HTML form to select and update book(s) from database using a JSP & a JavaBean: kread_dbBookTest08.jsp
  19. Read a flat file and convert to SQL: convertQFile.jsp


  20. Custom JSP & JSTL Tag Libraries
  21. Display message in JSP by calling a Custom JSP Tag: kread_Taglib_Test01.jsp
  22. Display message in JSP by calling a Custom JSP Tag: kread_Taglib_Test02.jsp
  23. Display message in JSP using JSTL: kread_JSTL_Test01.jsp
  24. Display message in a JSP by calling a Custom JSP Tag: antm_taglib_test01.jsp
  25. Call Custom Tag to retrieve data from a Java Bean, then JSP displays the data: antm_taglib_test02.jsp
  26. <Description>: <link to .JSP>
  27. <Description>: <link to .JSP>
  28. <Description>: <link to .JSP>
  29. <Description>: <link to .JSP>

[Top]

1The exercises listed here are from several books I am using to learn JSP. Some have been modified by me for practice, but all were inspired by one of several texts including the following. "Sams Teach Yourself JavaServerPages in 24 Hours" by Jose Annunaiato and Stephanie Fesler Kaminaris; "JavaServer Pages" by Hans Bergsten; "Mac OS X for Java Geeks" by Will Iverson..


Comments | Doug and Kris' Home Page | Kris' Page | Doug's Page | Site Map