Skip to content

Commit

Permalink
First commit
Browse files Browse the repository at this point in the history
  • Loading branch information
laniywh committed Dec 18, 2016
0 parents commit c741da6
Show file tree
Hide file tree
Showing 42 changed files with 1,591 additions and 0 deletions.
17 changes: 17 additions & 0 deletions .classpath
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.launching.macosx.MacOSXType/Java SE 8 [1.8.0_45]">
<attributes>
<attribute name="owner.project.facets" value="java"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jst.server.core.container/org.eclipse.jst.server.tomcat.runtimeTarget/Apache Tomcat v8.5.9">
<attributes>
<attribute name="owner.project.facets" value="jst.web"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.web.container"/>
<classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.module.container"/>
<classpathentry kind="output" path="build/classes"/>
</classpath>
1 change: 1 addition & 0 deletions .gitignore
@@ -0,0 +1 @@
/build/
31 changes: 31 additions & 0 deletions .project
@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>SimpleWebApp</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>
</buildSpec>
<natures>
<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 changes: 12 additions & 0 deletions .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>
7 changes: 7 additions & 0 deletions .settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,7 @@
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.source=1.8
8 changes: 8 additions & 0 deletions .settings/org.eclipse.wst.common.component
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
<wb-module deploy-name="SimpleWebApp">
<wb-resource deploy-path="/" source-path="/WebContent" tag="defaultRootSource"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src"/>
<property name="context-root" value="SimpleWebApp"/>
<property name="java-output-path" value="/SimpleWebApp/build/classes"/>
</wb-module>
</project-modules>
10 changes: 10 additions & 0 deletions .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 v8.5.9"/>
<fixed facet="java"/>
<fixed facet="jst.web"/>
<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 change: 1 addition & 0 deletions .settings/org.eclipse.wst.jsdt.ui.superType.container
@@ -0,0 +1 @@
org.eclipse.wst.jsdt.launching.baseBrowserLibrary
1 change: 1 addition & 0 deletions .settings/org.eclipse.wst.jsdt.ui.superType.name
@@ -0,0 +1 @@
Window
3 changes: 3 additions & 0 deletions WebContent/META-INF/MANIFEST.MF
@@ -0,0 +1,3 @@
Manifest-Version: 1.0
Class-Path:

Binary file not shown.
Binary file not shown.
Binary file not shown.
54 changes: 54 additions & 0 deletions WebContent/WEB-INF/tags/wrapper.tag
@@ -0,0 +1,54 @@
<%@tag description="Page Wrapper Tag" pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@attribute name="title" required="true" %>

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>${pageTitle}</title>
<link rel="stylesheet" href="<c:url value="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.5/css/bootstrap.min.css" />
" integrity="sha384-AysaV+vQoT3kOAXZkl02PThvDr8HYKPZhNT5h/CXfBThSRXQ6jW5DO2ekP5ViFdi" crossorigin="anonymous">
<link href="<c:url value="/styles.css" />
" rel="stylesheet">
</head>
<body>

<nav class="navbar navbar-light bg-faded">
<h3 class="site-name float-md-left">My Simple JSP Web Application</h3>
<ul class="nav navbar-nav float-md-right">
<li class="nav-item">
<a class="nav-link" href="${pageContext.request.contextPath}/">Home</a>
</li>
<li class="nav-item">
<a class="nav-link" href="${pageContext.request.contextPath}/productList">Product List</a>
</li>
<li class="nav-item">
<a class="nav-link" href="${pageContext.request.contextPath}/userInfo">My Account</a>
</li>
<li class="nav-item dropdown">
<a class="nav-link" href="${pageContext.request.contextPath}/login">Login</a>
</li>
</ul>
</nav>

<div class="container">
<div class="row header">
<div class="col-sm-8">
<h2 class="page-title">${title}</h2>
</div>

<div class="col-sm-4">
<!-- User store in session with attribute: loginedUser -->
<p class="greeting text-sm-right">
Hello <b>${loginedUser.userName}</b>
</p>
</div>
</div>

<jsp:doBody/>
</div>

<script src="<c:url value="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.5/js/bootstrap.min.js" /> integrity="sha384-BLiI7JTZm+JWlgKa0M0kGRpJbF2J8q+qreVrKBC47e3K6BW78kGLrCkeRX6I9RoK" crossorigin="anonymous"></script>
</body>
</html>
30 changes: 30 additions & 0 deletions WebContent/WEB-INF/views/createProductView.jsp
@@ -0,0 +1,30 @@
<%@page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@taglib prefix="t" tagdir="/WEB-INF/tags" %>

<t:wrapper title="Create Product">

<p style="color: red;">${errorString}</p>

<form method="POST" action="doCreateProduct">
<div class="form-group row">
<label for="code" class="col-xs-2 col-form-label">Code</label>
<div class="col-xs-5">
<input type="text" class="form-control" id="code" name="code" value="${product.code}">
</div>
</div>
<div class="form-group row">
<label for="name" class="col-xs-2 col-form-label">Name</label>
<div class="col-xs-5">
<input type="text" class="form-control" id="name" name="name" value="${product.name}">
</div>
</div>
<div class="form-group row">
<label for="price" class="col-xs-2 col-form-label">Price</label>
<div class="col-xs-5">
<input type="text" class="form-control" id="price" name="price" value="${product.price}">
</div>
</div>
<button type="submit" class="btn btn-submit">Submit</button>
<a href="${pageContext.request.contextPath}/productList">Cancel</a>
</form>
</t:wrapper>
7 changes: 7 additions & 0 deletions WebContent/WEB-INF/views/deleteProductErrorView.jsp
@@ -0,0 +1,7 @@
<%@page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@taglib prefix="t" tagdir="/WEB-INF/tags" %>

<t:wrapper title="Delete Product">
<p class="error">${errorString}</p>
<a href="productList">Product List</a>
</t:wrapper>
28 changes: 28 additions & 0 deletions WebContent/WEB-INF/views/editProductView.jsp
@@ -0,0 +1,28 @@
<%@page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@taglib prefix="t" tagdir="/WEB-INF/tags" %>

<t:wrapper title="Edit Product">

<p class="error">${errorString}</p>

<c:if test="${not empty product}">
<form method="POST" action="doEditProduct">
<input type="hidden" name="code" value="${product.code}" />
<div class="form-group row">
<label for="name" class="col-xs-2 col-form-label">Name</label>
<div class="col-xs-5">
<input type="text" class="form-control" id="name" name="name" value="${product.name}">
</div>
</div>
<div class="form-group row">
<label for="price" class="col-xs-2 col-form-label">Price</label>
<div class="col-xs-5">
<input type="text" class="form-control" id="price" name="price" value="${product.price}">
</div>
</div>
<button type="submit" class="btn btn-submit">Submit</button>
<a href="${pageContext.request.contextPath}/productList">Cancel</a>
</form>
</c:if>
</t:wrapper>
17 changes: 17 additions & 0 deletions WebContent/WEB-INF/views/homeView.jsp
@@ -0,0 +1,17 @@
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@taglib prefix="t" tagdir="/WEB-INF/tags" %>

<t:wrapper title="Home">
This is demo Simple web application using jsp,servlet &amp; Jdbc.
<br>
<br> <b>It includes the following functions:</b>
<ul class="list-unstyled">
<li>Login</li>
<li>Storing user information in cookies</li>
<li>Product List</li>
<li>Create Product</li>
<li>Edit Product</li>
<li>Delete Product</li>
</ul>

</t:wrapper>
35 changes: 35 additions & 0 deletions WebContent/WEB-INF/views/loginView.jsp
@@ -0,0 +1,35 @@
<%@page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@taglib prefix="t" tagdir="/WEB-INF/tags" %>

<t:wrapper title="Login">
<p class="error">${errorString}</p>

<form method="POST" action="doLogin">
<div class="form-group row">
<label for="userName" class="col-xs-2 col-form-label">Username</label>
<div class="col-xs-5">
<input type="text" class="form-control" id="userName" name="userName" value="${user.userName}">
</div>
</div>

<div class="form-group row">
<label for="password" class="col-xs-2 col-form-label">Password</label>
<div class="col-xs-5">
<input type="password" class="form-control" id="password" name="password" value="${user.password}">
</div>
</div>

<div class="form-group">
<label class="custom-control custom-checkbox">
<input type="checkbox" class="custom-control-input">
<span class="custom-control-indicator"></span>
<span class="custom-control-description">Remember me</span>
</label>
</div>

<input type="submit" class="btn btn-submit" value= "Submit" />
<a href="${pageContext.request.contextPath}/">Cancel</a>
</form>

<p class="login-info">User Name: lani, password: lani001 or tom/tom001 or jerry/jerry001</p>
</t:wrapper>
34 changes: 34 additions & 0 deletions WebContent/WEB-INF/views/productListView.jsp
@@ -0,0 +1,34 @@
<%@page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@taglib prefix="t" tagdir="/WEB-INF/tags" %>

<t:wrapper title="Product List">

<p class="error">${errorString}</p>

<table class="table table-striped">
<tr>
<th>Code</th>
<th>Name</th>
<th>Price</th>
<th>Edit</th>
<th>Delete</th>
</tr>
<c:forEach items="${productList}" var="product" >
<tr>
<td>${product.code}</td>
<td>${product.name}</td>
<td>${product.price}</td>
<td>
<a href="editProduct?code=${product.code}">Edit</a>
</td>
<td>
<a href="deleteProduct?code=${product.code}">Delete</a>
</td>
</tr>
</c:forEach>
</table>

<a class="btn btn-primary" role="button" href="createProduct" >Create Product</a>

</t:wrapper>
9 changes: 9 additions & 0 deletions WebContent/WEB-INF/views/userInfoView.jsp
@@ -0,0 +1,9 @@
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@taglib prefix="t" tagdir="/WEB-INF/tags" %>

<t:wrapper title="My Account">
User Name: <b>${user.userName}</b>
<br />
Gender: ${user.gender}
<br />
</t:wrapper>
16 changes: 16 additions & 0 deletions WebContent/WEB-INF/web.xml
@@ -0,0 +1,16 @@
<?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>SimpleWebApp</display-name>
<welcome-file-list>
<welcome-file>home</welcome-file>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
<filter-mapping>
<filter-name>jdbcFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>cookieFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
</web-app>
39 changes: 39 additions & 0 deletions WebContent/styles.css
@@ -0,0 +1,39 @@
body {
font-size: 16px;
}

h2 {
margin-bottom: 20px;
}

.container {
max-width: 700px;
padding: 0 20px;
}

.site-name {
margin: 0;
padding: 5px 0;
}

.navbar {
padding: 20px 40px;
font-size: .9rem;

}
.nav-link {
text-transform: uppercase;
}

.header {
padding-top: 2rem;
}

.btn-submit {
margin-right: 20px;
}

.login-info {
margin-top: 20px;
color: #AAACAC;
}

0 comments on commit c741da6

Please sign in to comment.