Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Keshav Mohan(1710991398)6G-01/WebContent/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Manifest-Version: 1.0
Class-Path:

Binary file not shown.
Binary file not shown.
Binary file not shown.
55 changes: 55 additions & 0 deletions Keshav Mohan(1710991398)6G-01/WebContent/WEB-INF/tags/wrapper.tag
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<%@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">
<meta name="viewport" content="width=device-width, initial-scale=1">
<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>
Original file line number Diff line number Diff line change
@@ -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>
Original file line number Diff line number Diff line change
@@ -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>
Original file line number Diff line number Diff line change
@@ -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>
Original file line number Diff line number Diff line change
@@ -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>
Original file line number Diff line number Diff line change
@@ -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>
Original file line number Diff line number Diff line change
@@ -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>
Original file line number Diff line number Diff line change
@@ -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 Keshav Mohan(1710991398)6G-01/WebContent/WEB-INF/web.xml
Original file line number Diff line number Diff line change
@@ -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 Keshav Mohan(1710991398)6G-01/WebContent/styles.css
Original file line number Diff line number Diff line change
@@ -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;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package com.lanihuang.simplewebapp.beans;

public class Product {

private String code;
private String name;
private float price;

public Product() {

}

public Product(String code, String name, float price) {
this.code = code;
this.name = name;
this.price = price;
}

public String getCode() {
return code;
}

public void setCode(String code) {
this.code = code;
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public float getPrice() {
return price;
}

public void setPrice(float price) {
this.price = price;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package com.lanihuang.simplewebapp.beans;

public class UserAccount {

public static final String GENDER_MALE = "M";
public static final String GENDER_FEMALE = "F";

private String userName;
private String gender;
private String password;


public UserAccount() {

}

public String getUserName() {
return userName;
}

public void setUserName(String userName) {
this.userName = userName;
}

public String getGender() {
return gender;
}

public void setGender(String gender) {
this.gender = gender;
}

public String getPassword() {
return password;
}

public void setPassword(String password) {
this.password = password;
}

}
Loading