home.jsp 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
  2. pageEncoding="ISO-8859-1" session="true"%>
  3. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  4. <html>
  5. <head>
  6. <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
  7. <title>Insert title here</title>
  8. </head>
  9. <body>
  10. <center>
  11. <font color="red" size=5><u>This is page two</u></font>
  12. <br /><br/>
  13. <%java.time.format.DateTimeFormatter dtf = java.time.format.DateTimeFormatter
  14. .ofPattern("yyyy/MM/dd HH:mm:ss");
  15. java.time.LocalDateTime now = java.time.LocalDateTime.now(); %>
  16. Current time : <%= now%></center>
  17. <br />
  18. <%
  19. session = request.getSession();
  20. //out.println("val = " + sessionFromReq);
  21. %><br/><br/>
  22. <%
  23. //out.println("val of session = " + session);
  24. //out.println("val of session = " + session);
  25. String nameVal = "null Name";
  26. String tmVal = "null Time";
  27. if (null != session.getAttribute("name")) {
  28. nameVal = String.valueOf(session.getAttribute("name"));
  29. }
  30. //out.println("<br/>Input Text : " + nameVal);
  31. if (null != session.getAttribute("currTime")) {
  32. tmVal = session.getAttribute("currTime").toString();
  33. }
  34. //out.println("<br/><br/>Time : " + tmVal + "<br/>");
  35. //String nameFromPage3 = String.valueOf(session.getAttribute("nameFromPage3"));
  36. if ("Go to page 3".equals(request.getParameter("bSubmit"))) {
  37. %>
  38. <jsp:forward page="thirdpage.jsp" />
  39. <%
  40. }if ("Go to page 1".equals(request.getParameter("bBack"))) {
  41. %>
  42. <jsp:forward page="index.jsp" />
  43. <%} %>
  44. <form action="home.jsp" method="get">
  45. <br /> <br />
  46. <table align="center">
  47. <%
  48. %>
  49. <tr>
  50. <td>Session Text :</td>
  51. <td><%=nameVal%></td>
  52. </tr>
  53. <tr>
  54. <td></td>
  55. </tr>
  56. <tr>
  57. <td>Session Time :</td>
  58. <td><%=tmVal%></td>
  59. </tr>
  60. <tr>
  61. <td></td>
  62. </tr>
  63. <tr>
  64. <td></td>
  65. </tr>
  66. <tr>
  67. <td><input type="submit" name="bBack"
  68. value="Go to page 1"></td>
  69. <td><input type="submit" name="bSubmit"
  70. value="Go to page 3"></td>
  71. </tr>
  72. </table>
  73. </form>
  74. </body>
  75. </html>