Browse Source

Session Testing App

PRADHAP KUMAR E 5 years ago
commit
a31b47c85f

+ 26 - 0
.classpath

@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="src" output="target/classes" path="src">
+		<attributes>
+			<attribute name="optional" value="true"/>
+			<attribute name="maven.pomderived" value="true"/>
+		</attributes>
+	</classpathentry>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
+		<attributes>
+			<attribute name="maven.pomderived" value="true"/>
+		</attributes>
+	</classpathentry>
+	<classpathentry kind="con" path="org.eclipse.jst.server.core.container/org.eclipse.jst.server.tomcat.runtimeTarget/Apache Tomcat v9.0">
+		<attributes>
+			<attribute name="owner.project.facets" value="jst.web"/>
+		</attributes>
+	</classpathentry>
+	<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
+		<attributes>
+			<attribute name="maven.pomderived" value="true"/>
+			<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
+		</attributes>
+	</classpathentry>
+	<classpathentry kind="output" path="target/classes"/>
+</classpath>

+ 37 - 0
.project

@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>TestSessionDynWebApp</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.eclipse.jdt.core.javabuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.wst.common.project.facet.core.builder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.wst.validation.validationbuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.m2e.core.maven2Builder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.eclipse.m2e.core.maven2Nature</nature>
+		<nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
+		<nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>
+		<nature>org.eclipse.wst.common.project.facet.core.nature</nature>
+		<nature>org.eclipse.jdt.core.javanature</nature>
+		<nature>org.eclipse.wst.jsdt.core.jsNature</nature>
+	</natures>
+</projectDescription>

+ 12 - 0
.settings/.jsdtscope

@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry excluding="**/bower_components/*|**/node_modules/*|**/*.min.js" kind="src" path="WebContent"/>
+	<classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.JRE_CONTAINER"/>
+	<classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.WebProject">
+		<attributes>
+			<attribute name="hide" value="true"/>
+		</attributes>
+	</classpathentry>
+	<classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.baseBrowserLibrary"/>
+	<classpathentry kind="output" path=""/>
+</classpath>

+ 8 - 0
.settings/org.eclipse.jdt.core.prefs

@@ -0,0 +1,8 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
+org.eclipse.jdt.core.compiler.compliance=1.8
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
+org.eclipse.jdt.core.compiler.source=1.8

+ 4 - 0
.settings/org.eclipse.m2e.core.prefs

@@ -0,0 +1,4 @@
+activeProfiles=
+eclipse.preferences.version=1
+resolveWorkspaceProjects=true
+version=1

+ 9 - 0
.settings/org.eclipse.wst.common.component

@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
+    <wb-module deploy-name="TestSessionDynWebApp-0.0.1-SNAPSHOT">
+        <wb-resource deploy-path="/" source-path="/target/m2e-wtp/web-resources"/>
+        <wb-resource deploy-path="/" source-path="/WebContent" tag="defaultRootSource"/>
+        <wb-resource deploy-path="/WEB-INF/classes" source-path="/src"/>
+        <property name="context-root" value="TestSessionDynWebApp"/>
+        <property name="java-output-path" value="/TestSessionDynWebApp/build/classes"/>
+    </wb-module>
+</project-modules>

+ 10 - 0
.settings/org.eclipse.wst.common.project.facet.core.xml

@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<faceted-project>
+  <runtime name="Apache Tomcat v9.0"/>
+  <fixed facet="jst.web"/>
+  <fixed facet="java"/>
+  <fixed facet="wst.jsdt.web"/>
+  <installed facet="java" version="1.8"/>
+  <installed facet="jst.web" version="3.1"/>
+  <installed facet="wst.jsdt.web" version="1.0"/>
+</faceted-project>

+ 1 - 0
.settings/org.eclipse.wst.jsdt.ui.superType.container

@@ -0,0 +1 @@
+org.eclipse.wst.jsdt.launching.baseBrowserLibrary

+ 1 - 0
.settings/org.eclipse.wst.jsdt.ui.superType.name

@@ -0,0 +1 @@
+Window

+ 2 - 0
.settings/org.eclipse.wst.validation.prefs

@@ -0,0 +1,2 @@
+disabled=06target
+eclipse.preferences.version=1

+ 3 - 0
WebContent/META-INF/MANIFEST.MF

@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+Class-Path: 
+

+ 12 - 0
WebContent/WEB-INF/web.xml

@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" id="WebApp_ID" version="3.1">
+  <display-name>TestSessionDynWebApp</display-name>
+  <welcome-file-list>
+    <welcome-file>index.html</welcome-file>
+    <welcome-file>index.htm</welcome-file>
+    <welcome-file>index.jsp</welcome-file>
+    <welcome-file>default.html</welcome-file>
+    <welcome-file>default.htm</welcome-file>
+    <welcome-file>default.jsp</welcome-file>
+  </welcome-file-list>
+</web-app>

+ 85 - 0
WebContent/home.jsp

@@ -0,0 +1,85 @@
+<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
+	pageEncoding="ISO-8859-1" session="true"%>
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
+<title>Insert title here</title>
+</head>
+
+<body>
+	<center>
+		<font color="red" size=5><u>This is page two</u></font>
+	
+	<br /><br/>
+	 <%java.time.format.DateTimeFormatter dtf = java.time.format.DateTimeFormatter
+			.ofPattern("yyyy/MM/dd HH:mm:ss");
+	java.time.LocalDateTime now = java.time.LocalDateTime.now(); %>
+	Current time : <%= now%></center>
+	<br />
+
+	<%
+	
+	 session = request.getSession();
+	//out.println("val = " + sessionFromReq);
+	%><br/><br/>
+	<%
+	//out.println("val of session = " + session);
+	
+	//out.println("val of session = " + session);
+	
+	String nameVal = "null Name";
+	String tmVal = "null Time";
+	if (null != session.getAttribute("name")) {
+		 nameVal = String.valueOf(session.getAttribute("name"));
+	}
+		//out.println("<br/>Input Text : " + nameVal);
+		if (null != session.getAttribute("currTime")) {
+		 tmVal = session.getAttribute("currTime").toString();
+		}
+		//out.println("<br/><br/>Time : " + tmVal + "<br/>");
+		//String nameFromPage3 = String.valueOf(session.getAttribute("nameFromPage3"));
+
+		if ("Go to page 3".equals(request.getParameter("bSubmit"))) {
+	%>
+	<jsp:forward page="thirdpage.jsp" />
+	<%
+		}if ("Go to page 1".equals(request.getParameter("bBack"))) {
+	%>
+<jsp:forward page="index.jsp" />
+<%} %>
+
+
+	<form action="home.jsp" method="get">
+		<br /> <br />
+		<table align="center">
+			<%
+				
+			%>
+			<tr>
+				<td>Session Text :</td>
+				<td><%=nameVal%></td>
+			</tr>
+			<tr>
+				<td></td>
+			</tr>
+			<tr>
+				<td>Session Time :</td>
+				<td><%=tmVal%></td>
+			</tr>
+			<tr>
+				<td></td>
+			</tr>
+			<tr>
+				<td></td>
+			</tr>
+			<tr>
+			<td><input type="submit" name="bBack"
+					value="Go to page 1"></td>
+				<td><input type="submit" name="bSubmit"
+					value="Go to page 3"></td>
+			</tr>
+		</table>
+	</form>
+</body>
+</html>

+ 55 - 0
WebContent/index.jsp

@@ -0,0 +1,55 @@
+<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1" session="true"%>
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<%-- <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> --%>
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
+<title>Insert title here</title>
+</head>
+<%
+	session = request.getSession();
+	String sessionValue = "null Name.....";
+	if (null != session.getAttribute("name")) {
+		sessionValue = (String) session.getAttribute("name");
+	}
+	if ("Start".equals(request.getParameter("bSubmit"))) {
+		session.setAttribute("name", request.getParameter("tName"));
+		java.time.format.DateTimeFormatter dtf1 = java.time.format.DateTimeFormatter.ofPattern("yyyy/MM/dd HH:mm:ss");
+		java.time.LocalDateTime now1 = java.time.LocalDateTime.now();
+		session.setAttribute("currTime", now1);
+%>
+<jsp:forward page="home.jsp" />
+<%
+	}
+%>
+<body>
+	<center>
+		<font color="red" size=5><u>Welcome to Session Testing</u></font><br />
+		<br />
+		<%
+			java.time.format.DateTimeFormatter dtf = java.time.format.DateTimeFormatter.ofPattern("yyyy/MM/dd HH:mm:ss");
+			java.time.LocalDateTime now = java.time.LocalDateTime.now();
+		%>
+		Current time :
+		<%=now%>
+	</center>
+	<br />
+	<br />
+	<form action="index.jsp" method="get">
+		<table align="center">
+			<tr>
+				<td>Enter Name :</td>
+				<%-- <td><input type="text" name="tName"
+					value="<%=("".equals(sessionValue) || (null == sessionValue)) ? "" : sessionValue%>">
+				<td> --%>
+				<td><input type="text" name="tName"
+					value="${sessionValue}">
+				<td>
+			</tr>
+			<tr>
+				<td colspan="2"><input type="submit" name="bSubmit" value="Start"></td>
+			</tr>
+		</table>
+	</form>
+</body>
+</html>

+ 76 - 0
WebContent/second.jsp

@@ -0,0 +1,76 @@
+<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
+	pageEncoding="ISO-8859-1"%>
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
+<title>Insert title here</title>
+</head>
+
+<body>
+	<center>
+		<font color="red" size=5><u>This is page two</u></font>
+	
+	<br /><br/>
+	 <%java.time.format.DateTimeFormatter dtf = java.time.format.DateTimeFormatter
+			.ofPattern("yyyy/MM/dd HH:mm:ss");
+	java.time.LocalDateTime now = java.time.LocalDateTime.now(); %>
+	Current time : <%= now%></center>
+	<br />
+
+	<%
+	String nameVal = "null Name";
+	String tmVal = "null Time";
+	if (null != session.getAttribute("name")) {
+		 nameVal = String.valueOf(session.getAttribute("name"));
+	}
+		//out.println("<br/>Input Text : " + nameVal);
+		if (null != session.getAttribute("currTime")) {
+		 tmVal = session.getAttribute("currTime").toString();
+		}
+		//out.println("<br/><br/>Time : " + tmVal + "<br/>");
+		//String nameFromPage3 = String.valueOf(session.getAttribute("nameFromPage3"));
+
+		if ("Go to page 3".equals(request.getParameter("bSubmit"))) {
+	%>
+	<jsp:forward page="thirdpage.jsp" />
+	<%
+		}if ("Go to page 1".equals(request.getParameter("bBack"))) {
+	%>
+<jsp:forward page="index.jsp" />
+<%} %>
+
+
+	<form action="home.jsp" method="get">
+		<br /> <br />
+		<table align="center">
+			<%
+				
+			%>
+			<tr>
+				<td>Session Text :</td>
+				<td><%=nameVal%></td>
+			</tr>
+			<tr>
+				<td></td>
+			</tr>
+			<tr>
+				<td>Session Time :</td>
+				<td><%=tmVal%></td>
+			</tr>
+			<tr>
+				<td></td>
+			</tr>
+			<tr>
+				<td></td>
+			</tr>
+			<tr>
+			<td><input type="submit" name="bBack"
+					value="Go to page 1"></td>
+				<td><input type="submit" name="bSubmit"
+					value="Go to page 3"></td>
+			</tr>
+		</table>
+	</form>
+</body>
+</html>

+ 78 - 0
WebContent/thirdpage.jsp

@@ -0,0 +1,78 @@
+<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
+	pageEncoding="ISO-8859-1" session="true"%>
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
+<title>Insert title here</title>
+</head>
+<body>
+	<center>
+		<font color="red" size=5><u>This is page three</u></font> <br /> <br />
+		<%
+			java.time.format.DateTimeFormatter dtf1 = java.time.format.DateTimeFormatter
+					.ofPattern("yyyy/MM/dd HH:mm:ss");
+			java.time.LocalDateTime now1 = java.time.LocalDateTime.now();
+		%>
+		Current time :
+		<%=now1%></center>
+
+	<br />
+	<%
+		session = request.getSession();
+		String nameVal = "null name";
+		String tmVal = "null time";
+		if (null != session.getAttribute("name")) {
+			nameVal = String.valueOf(session.getAttribute("name"));
+		}
+		//out.println("<br/>3rd page : " + nameVal);
+		if (null != session.getAttribute("currTime")) {
+			tmVal = session.getAttribute("currTime").toString();
+		}
+		//out.println("<br/><br/>Time is : " + tmVal);
+
+		if ("Go Back".equals(request.getParameter("bSubmit"))) {
+			session.setAttribute("name", request.getParameter("tName"));
+
+			java.time.format.DateTimeFormatter dtf = java.time.format.DateTimeFormatter
+					.ofPattern("yyyy/MM/dd HH:mm:ss");
+			java.time.LocalDateTime now = java.time.LocalDateTime.now();
+			//System.out.println(dtf.format(now));
+			session.setAttribute("currTime", now);
+	%>
+			<jsp:forward page="home.jsp" />
+	<%
+		}
+	%>
+	<form action="thirdpage.jsp" method="get">
+		<table align="center">
+			<tr>
+				<td>Session Text :</td>
+				<td><%=nameVal%></td>
+			</tr>
+			<tr>
+				<td></td>
+			</tr>
+			<tr>
+				<td>Session Time :</td>
+				<td><%=tmVal%></td>
+			</tr>
+			<tr>
+				<td></td>
+			</tr>
+			<tr>
+				<td></td>
+			</tr>
+			<tr>
+				<td>Enter Name :</td>
+				<td><input type="text" name="tName">
+				<td>
+			</tr>
+			<tr>
+				<td colspan="2"><input type="submit" name="bSubmit"
+					value="Go Back"></td>
+			</tr>
+		</table>
+	</form>
+</body>
+</html>

BIN
build/classes/pkg/Person.class


+ 27 - 0
pom.xml

@@ -0,0 +1,27 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>TestSessionDynWebApp</groupId>
+  <artifactId>TestSessionDynWebApp</artifactId>
+  <version>0.0.1-SNAPSHOT</version>
+  <packaging>war</packaging>
+  <build>
+    <sourceDirectory>src</sourceDirectory>
+    <plugins>
+      <plugin>
+        <artifactId>maven-compiler-plugin</artifactId>
+        <version>3.7.0</version>
+        <configuration>
+          <source>1.8</source>
+          <target>1.8</target>
+        </configuration>
+      </plugin>
+      <plugin>
+        <artifactId>maven-war-plugin</artifactId>
+        <version>3.0.0</version>
+        <configuration>
+          <warSourceDirectory>WebContent</warSourceDirectory>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+</project>

+ 19 - 0
src/pkg/Person.java

@@ -0,0 +1,19 @@
+/**
+ * 
+ */
+package pkg;
+
+/**
+ * @author SE420
+ *
+ */
+public class Person {
+
+	/**
+	 * 
+	 */
+	public Person() {
+		// TODO Auto-generated constructor stub
+	}
+
+}

BIN
target/classes/pkg/Person.class


+ 1 - 0
target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst

@@ -0,0 +1 @@
+pkg\Person.class

+ 1 - 0
target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst

@@ -0,0 +1 @@
+D:\EclipseWorkspace\_Session_Work\SessionTesting\src\pkg\Person.java