second.jsp 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
  2. pageEncoding="ISO-8859-1"%>
  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. String nameVal = "null Name";
  20. String tmVal = "null Time";
  21. if (null != session.getAttribute("name")) {
  22. nameVal = String.valueOf(session.getAttribute("name"));
  23. }
  24. //out.println("<br/>Input Text : " + nameVal);
  25. if (null != session.getAttribute("currTime")) {
  26. tmVal = session.getAttribute("currTime").toString();
  27. }
  28. //out.println("<br/><br/>Time : " + tmVal + "<br/>");
  29. //String nameFromPage3 = String.valueOf(session.getAttribute("nameFromPage3"));
  30. if ("Go to page 3".equals(request.getParameter("bSubmit"))) {
  31. %>
  32. <jsp:forward page="thirdpage.jsp" />
  33. <%
  34. }if ("Go to page 1".equals(request.getParameter("bBack"))) {
  35. %>
  36. <jsp:forward page="index.jsp" />
  37. <%} %>
  38. <form action="home.jsp" method="get">
  39. <br /> <br />
  40. <table align="center">
  41. <%
  42. %>
  43. <tr>
  44. <td>Session Text :</td>
  45. <td><%=nameVal%></td>
  46. </tr>
  47. <tr>
  48. <td></td>
  49. </tr>
  50. <tr>
  51. <td>Session Time :</td>
  52. <td><%=tmVal%></td>
  53. </tr>
  54. <tr>
  55. <td></td>
  56. </tr>
  57. <tr>
  58. <td></td>
  59. </tr>
  60. <tr>
  61. <td><input type="submit" name="bBack"
  62. value="Go to page 1"></td>
  63. <td><input type="submit" name="bSubmit"
  64. value="Go to page 3"></td>
  65. </tr>
  66. </table>
  67. </form>
  68. </body>
  69. </html>