thirdpage.jsp 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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 three</u></font> <br /> <br />
  12. <%
  13. java.time.format.DateTimeFormatter dtf1 = java.time.format.DateTimeFormatter
  14. .ofPattern("yyyy/MM/dd HH:mm:ss");
  15. java.time.LocalDateTime now1 = java.time.LocalDateTime.now();
  16. %>
  17. Current time :
  18. <%=now1%></center>
  19. <br />
  20. <%
  21. session = request.getSession();
  22. String nameVal = "null name";
  23. String tmVal = "null time";
  24. if (null != session.getAttribute("name")) {
  25. nameVal = String.valueOf(session.getAttribute("name"));
  26. }
  27. //out.println("<br/>3rd page : " + nameVal);
  28. if (null != session.getAttribute("currTime")) {
  29. tmVal = session.getAttribute("currTime").toString();
  30. }
  31. //out.println("<br/><br/>Time is : " + tmVal);
  32. if ("Go Back".equals(request.getParameter("bSubmit"))) {
  33. session.setAttribute("name", request.getParameter("tName"));
  34. java.time.format.DateTimeFormatter dtf = java.time.format.DateTimeFormatter
  35. .ofPattern("yyyy/MM/dd HH:mm:ss");
  36. java.time.LocalDateTime now = java.time.LocalDateTime.now();
  37. //System.out.println(dtf.format(now));
  38. session.setAttribute("currTime", now);
  39. %>
  40. <jsp:forward page="home.jsp" />
  41. <%
  42. }
  43. %>
  44. <form action="thirdpage.jsp" method="get">
  45. <table align="center">
  46. <tr>
  47. <td>Session Text :</td>
  48. <td><%=nameVal%></td>
  49. </tr>
  50. <tr>
  51. <td></td>
  52. </tr>
  53. <tr>
  54. <td>Session Time :</td>
  55. <td><%=tmVal%></td>
  56. </tr>
  57. <tr>
  58. <td></td>
  59. </tr>
  60. <tr>
  61. <td></td>
  62. </tr>
  63. <tr>
  64. <td>Enter Name :</td>
  65. <td><input type="text" name="tName">
  66. <td>
  67. </tr>
  68. <tr>
  69. <td colspan="2"><input type="submit" name="bSubmit"
  70. value="Go Back"></td>
  71. </tr>
  72. </table>
  73. </form>
  74. </body>
  75. </html>