esoe
2 years ago
28 changed files with 687 additions and 0 deletions
@ -0,0 +1,77 @@
@@ -0,0 +1,77 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
|
||||
<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>ru.molokoin</groupId> |
||||
<artifactId>exchange-servlet</artifactId> |
||||
<version>0.1</version> |
||||
<packaging>war</packaging> |
||||
|
||||
<name>exchange-servlet Maven Webapp</name> |
||||
<!-- FIXME change it to the project's website --> |
||||
<url>http://www.example.com</url> |
||||
|
||||
<properties> |
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> |
||||
<maven.compiler.source>1.7</maven.compiler.source> |
||||
<maven.compiler.target>1.7</maven.compiler.target> |
||||
</properties> |
||||
|
||||
<dependencies> |
||||
<dependency> |
||||
<groupId>javax.servlet</groupId> |
||||
<artifactId>javax.servlet-api</artifactId> |
||||
<version>3.1.0</version> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>javax.servlet.jsp</groupId> |
||||
<artifactId>jsp-api</artifactId> |
||||
<version>2.1</version> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>junit</groupId> |
||||
<artifactId>junit</artifactId> |
||||
<version>4.11</version> |
||||
<scope>test</scope> |
||||
</dependency> |
||||
</dependencies> |
||||
|
||||
<build> |
||||
<finalName>exchange-servlet</finalName> |
||||
<pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) --> |
||||
<plugins> |
||||
<plugin> |
||||
<artifactId>maven-clean-plugin</artifactId> |
||||
<version>3.1.0</version> |
||||
</plugin> |
||||
<!-- see http://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_war_packaging --> |
||||
<plugin> |
||||
<artifactId>maven-resources-plugin</artifactId> |
||||
<version>3.0.2</version> |
||||
</plugin> |
||||
<plugin> |
||||
<artifactId>maven-compiler-plugin</artifactId> |
||||
<version>3.8.0</version> |
||||
</plugin> |
||||
<plugin> |
||||
<artifactId>maven-surefire-plugin</artifactId> |
||||
<version>2.22.1</version> |
||||
</plugin> |
||||
<plugin> |
||||
<artifactId>maven-war-plugin</artifactId> |
||||
<version>3.2.2</version> |
||||
</plugin> |
||||
<plugin> |
||||
<artifactId>maven-install-plugin</artifactId> |
||||
<version>2.5.2</version> |
||||
</plugin> |
||||
<plugin> |
||||
<artifactId>maven-deploy-plugin</artifactId> |
||||
<version>2.8.2</version> |
||||
</plugin> |
||||
</plugins> |
||||
</pluginManagement> |
||||
</build> |
||||
</project> |
@ -0,0 +1,83 @@
@@ -0,0 +1,83 @@
|
||||
package ru.molokoin; |
||||
|
||||
import java.io.File; |
||||
import java.io.FileInputStream; |
||||
import java.io.IOException; |
||||
import java.io.OutputStream; |
||||
|
||||
import javax.servlet.ServletException; |
||||
import javax.servlet.annotation.WebServlet; |
||||
import javax.servlet.http.HttpServlet; |
||||
import javax.servlet.http.HttpServletRequest; |
||||
import javax.servlet.http.HttpServletResponse; |
||||
|
||||
@WebServlet(description = "Download File From The Server", urlPatterns = { "/downloadServlet" }) |
||||
public class FileDownloadServlet extends HttpServlet { |
||||
|
||||
private static final long serialVersionUID = 1L; |
||||
|
||||
public static int BUFFER_SIZE = 1024 * 100; |
||||
public static final String UPLOAD_DIR = "uploadedFiles"; |
||||
|
||||
/***** This Method Is Called By The Servlet Container To Process A 'GET' Request *****/ |
||||
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { |
||||
handleRequest(request, response); |
||||
} |
||||
|
||||
public void handleRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { |
||||
|
||||
/***** Get The Absolute Path Of The File To Be Downloaded *****/ |
||||
String fileName = request.getParameter("fileName"), |
||||
applicationPath = getServletContext().getRealPath(""), |
||||
downloadPath = applicationPath + File.separator + UPLOAD_DIR, |
||||
filePath = downloadPath + File.separator + fileName; |
||||
|
||||
File file = new File(filePath); |
||||
OutputStream outStream = null; |
||||
FileInputStream inputStream = null; |
||||
|
||||
if (file.exists()) { |
||||
|
||||
/**** Setting The Content Attributes For The Response Object ****/ |
||||
String mimeType = "application/octet-stream"; |
||||
response.setContentType(mimeType); |
||||
|
||||
/**** Setting The Headers For The Response Object ****/ |
||||
String headerKey = "Content-Disposition"; |
||||
String headerValue = String.format("attachment; filename=\"%s\"", file.getName()); |
||||
response.setHeader(headerKey, headerValue); |
||||
|
||||
try { |
||||
|
||||
/**** Get The Output Stream Of The Response ****/ |
||||
outStream = response.getOutputStream(); |
||||
inputStream = new FileInputStream(file); |
||||
byte[] buffer = new byte[BUFFER_SIZE]; |
||||
int bytesRead = -1; |
||||
|
||||
/**** Write Each Byte Of Data Read From The Input Stream Write Each Byte Of Data Read From The Input Stream Into The Output Stream ****/ |
||||
while ((bytesRead = inputStream.read(buffer)) != -1) { |
||||
outStream.write(buffer, 0, bytesRead); |
||||
} |
||||
} catch(IOException ioExObj) { |
||||
System.out.println("Exception While Performing The I/O Operation?= " + ioExObj.getMessage()); |
||||
} finally { |
||||
if (inputStream != null) { |
||||
inputStream.close(); |
||||
} |
||||
|
||||
outStream.flush(); |
||||
if (outStream != null) { |
||||
outStream.close(); |
||||
} |
||||
} |
||||
} else { |
||||
|
||||
/***** Set Response Content Type *****/ |
||||
response.setContentType("text/html"); |
||||
|
||||
/***** Print The Response *****/ |
||||
response.getWriter().println("<h3>File "+ fileName +" Is Not Present .....!</h3>"); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,75 @@
@@ -0,0 +1,75 @@
|
||||
package ru.molokoin; |
||||
|
||||
import java.io.File; |
||||
import java.io.IOException; |
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
|
||||
import javax.servlet.RequestDispatcher; |
||||
import javax.servlet.ServletException; |
||||
import javax.servlet.annotation.MultipartConfig; |
||||
import javax.servlet.annotation.WebServlet; |
||||
import javax.servlet.http.HttpServlet; |
||||
import javax.servlet.http.HttpServletRequest; |
||||
import javax.servlet.http.HttpServletResponse; |
||||
import javax.servlet.http.Part; |
||||
|
||||
@WebServlet(description = "Upload File To The Server", urlPatterns = { "/fileUploadServlet" }) |
||||
@MultipartConfig(fileSizeThreshold = 1024 * 1024 * 10, maxFileSize = 1024 * 1024 * 30, maxRequestSize = 1024 * 1024 * 50) |
||||
public class FileUploadServlet extends HttpServlet { |
||||
|
||||
private static final long serialVersionUID = 1L; |
||||
public static final String UPLOAD_DIR = "uploadedFiles"; |
||||
|
||||
/***** This Method Is Called By The Servlet Container To Process A 'POST' Request *****/ |
||||
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { |
||||
handleRequest(request, response); |
||||
} |
||||
|
||||
public void handleRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { |
||||
|
||||
/***** Get The Absolute Path Of The Web Application *****/ |
||||
String applicationPath = getServletContext().getRealPath(""), |
||||
uploadPath = applicationPath + File.separator + UPLOAD_DIR; |
||||
|
||||
File fileUploadDirectory = new File(uploadPath); |
||||
if (!fileUploadDirectory.exists()) { |
||||
fileUploadDirectory.mkdirs(); |
||||
} |
||||
|
||||
String fileName = ""; |
||||
UploadDetail details = null; |
||||
List<UploadDetail> fileList = new ArrayList<UploadDetail>(); |
||||
|
||||
for (Part part : request.getParts()) { |
||||
fileName = extractFileName(part); |
||||
details = new UploadDetail(); |
||||
details.setFileName(fileName); |
||||
details.setFileSize(part.getSize() / 1024); |
||||
try { |
||||
part.write(uploadPath + File.separator + fileName); |
||||
details.setUploadStatus("Success"); |
||||
} catch (IOException ioObj) { |
||||
details.setUploadStatus("Failure : "+ ioObj.getMessage()); |
||||
} |
||||
fileList.add(details); |
||||
} |
||||
|
||||
request.setAttribute("uploadedFiles", fileList); |
||||
RequestDispatcher dispatcher = request.getRequestDispatcher("/fileuploadResponse.jsp"); |
||||
dispatcher.forward(request, response); |
||||
} |
||||
|
||||
/***** Helper Method #1 - This Method Is Used To Read The File Names *****/ |
||||
private String extractFileName(Part part) { |
||||
String fileName = "", |
||||
contentDisposition = part.getHeader("content-disposition"); |
||||
String[] items = contentDisposition.split(";"); |
||||
for (String item : items) { |
||||
if (item.trim().startsWith("filename")) { |
||||
fileName = item.substring(item.indexOf("=") + 2, item.length() - 1); |
||||
} |
||||
} |
||||
return fileName; |
||||
} |
||||
} |
@ -0,0 +1,35 @@
@@ -0,0 +1,35 @@
|
||||
package ru.molokoin; |
||||
|
||||
import java.io.Serializable; |
||||
|
||||
public class UploadDetail implements Serializable { |
||||
|
||||
private long fileSize; |
||||
private String fileName, uploadStatus; |
||||
|
||||
private static final long serialVersionUID = 1L; |
||||
|
||||
public long getFileSize() { |
||||
return fileSize; |
||||
} |
||||
|
||||
public void setFileSize(long fileSize) { |
||||
this.fileSize = fileSize; |
||||
} |
||||
|
||||
public String getFileName() { |
||||
return fileName; |
||||
} |
||||
|
||||
public void setFileName(String fileName) { |
||||
this.fileName = fileName; |
||||
} |
||||
|
||||
public String getUploadStatus() { |
||||
return uploadStatus; |
||||
} |
||||
|
||||
public void setUploadStatus(String uploadStatus) { |
||||
this.uploadStatus = uploadStatus; |
||||
} |
||||
} |
@ -0,0 +1,52 @@
@@ -0,0 +1,52 @@
|
||||
package ru.molokoin; |
||||
|
||||
import java.io.File; |
||||
import java.io.IOException; |
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
|
||||
import javax.servlet.RequestDispatcher; |
||||
import javax.servlet.ServletException; |
||||
import javax.servlet.annotation.WebServlet; |
||||
import javax.servlet.http.HttpServlet; |
||||
import javax.servlet.http.HttpServletRequest; |
||||
import javax.servlet.http.HttpServletResponse; |
||||
|
||||
@WebServlet(description = "List The Already Uploaded Files", urlPatterns = { "/uploadedFilesServlet" }) |
||||
public class UploadedFilesServlet extends HttpServlet { |
||||
|
||||
private static final long serialVersionUID = 1L; |
||||
public static final String UPLOAD_DIR = "uploadedFiles"; |
||||
|
||||
/***** This Method Is Called By The Servlet Container To Process A 'GET' Request *****/ |
||||
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { |
||||
handleRequest(request, response); |
||||
} |
||||
|
||||
public void handleRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { |
||||
|
||||
/***** Get The Absolute Path Of The Web Application *****/ |
||||
String applicationPath = getServletContext().getRealPath(""), |
||||
uploadPath = applicationPath + File.separator + UPLOAD_DIR; |
||||
|
||||
File fileUploadDirectory = new File(uploadPath); |
||||
if (!fileUploadDirectory.exists()) { |
||||
fileUploadDirectory.mkdirs(); |
||||
} |
||||
|
||||
UploadDetail details = null; |
||||
File[] allFiles = fileUploadDirectory.listFiles(); |
||||
List<UploadDetail> fileList = new ArrayList<UploadDetail>(); |
||||
|
||||
for (File file : allFiles) { |
||||
details = new UploadDetail(); |
||||
details.setFileName(file.getName()); |
||||
details.setFileSize(file.length() / 1024); |
||||
fileList.add(details); |
||||
} |
||||
|
||||
request.setAttribute("uploadedFiles", fileList); |
||||
RequestDispatcher dispatcher = request.getRequestDispatcher("/allfiles.jsp"); |
||||
dispatcher.forward(request, response); |
||||
} |
||||
} |
@ -0,0 +1,10 @@
@@ -0,0 +1,10 @@
|
||||
<!DOCTYPE web-app PUBLIC |
||||
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" |
||||
"http://java.sun.com/dtd/web-app_2_3.dtd" > |
||||
|
||||
<web-app> |
||||
<display-name>exchange-servlet</display-name> |
||||
<welcome-file-list> |
||||
<welcome-file>fileupload.jsp</welcome-file> |
||||
</welcome-file-list> |
||||
</web-app> |
@ -0,0 +1,42 @@
@@ -0,0 +1,42 @@
|
||||
<%@page import="java.util.List"%> |
||||
<%@page import="ru.molokoin.UploadDetail"%> |
||||
<%@page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> |
||||
<!DOCTYPE html> |
||||
<html> |
||||
<head> |
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> |
||||
<title>exchange-servlet</title> |
||||
|
||||
<link rel="stylesheet" href="resource/css/main.css" /> |
||||
</head> |
||||
<body> |
||||
<div class="panel"> |
||||
<h1>Uploaded Files</h1> |
||||
<table class="bordered_table"> |
||||
<thead> |
||||
<tr align="center"><th>File Name</th><th>File Size</th><th>Action</th></tr> |
||||
</thead> |
||||
<tbody> |
||||
<% List<UploadDetail> uploadDetails = (List<UploadDetail>)request.getAttribute("uploadedFiles"); |
||||
if(uploadDetails != null && uploadDetails.size() > 0) { |
||||
for(int i=0; i<uploadDetails.size(); i++) { |
||||
%> |
||||
<tr> |
||||
<td align="center"><span id="fileName"><%=uploadDetails.get(i).getFileName() %></span></td> |
||||
<td align="center"><span id="fileSize"><%=uploadDetails.get(i).getFileSize() %> KB</span></td> |
||||
<td align="center"><span id="fileDownload"><a id="downloadLink" class="hyperLink" href="<%=request.getContextPath()%>/downloadServlet?fileName=<%=uploadDetails.get(i).getFileName() %>">Download</a></span></td> |
||||
</tr> |
||||
<% } |
||||
} else { %> |
||||
<tr> |
||||
<td colspan="3" align="center"><span id="noFiles">No Files Uploaded.....!</span></td> |
||||
</tr> |
||||
<% } %> |
||||
</tbody> |
||||
</table> |
||||
<div class="margin_top_15px"> |
||||
<a id="fileUpload" class="hyperLink" href="<%=request.getContextPath()%>/fileupload.jsp">Back</a> |
||||
</div> |
||||
</div> |
||||
</body> |
||||
</html> |
@ -0,0 +1,37 @@
@@ -0,0 +1,37 @@
|
||||
<%@page import="java.util.List"%> |
||||
<%@page import="ru.molokoin.UploadDetail"%> |
||||
<%@page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> |
||||
<!DOCTYPE html> |
||||
<html> |
||||
<head> |
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> |
||||
<title>exchange-servlet</title> |
||||
|
||||
<link rel="stylesheet" href="resource/css/main.css" /> |
||||
</head> |
||||
<body> |
||||
<div class="panel"> |
||||
<h1>File Upload Status</h1> |
||||
<table class="bordered_table"> |
||||
<thead> |
||||
<tr align="center"><th>File Name</th><th>File Size</th><th>Upload Status</th><th>Action</th></tr> |
||||
</thead> |
||||
<tbody> |
||||
<% List<UploadDetail> uploadDetails = (List<UploadDetail>)request.getAttribute("uploadedFiles"); |
||||
for(int i=0; i<uploadDetails.size(); i++) { |
||||
%> |
||||
<tr> |
||||
<td align="center"><span id="fileName"><%=uploadDetails.get(i).getFileName() %></span></td> |
||||
<td align="center"><span id="fileSize"><%=uploadDetails.get(i).getFileSize() %> KB</span></td> |
||||
<td align="center"><span id="fileuploadStatus"><%=uploadDetails.get(i).getUploadStatus() %></span></td> |
||||
<td align="center"><span id="fileDownload"><a id="downloadLink" class="hyperLink" href="<%=request.getContextPath()%>/downloadServlet?fileName=<%=uploadDetails.get(i).getFileName() %>">Download</a></span></td> |
||||
</tr> |
||||
<% } %> |
||||
</tbody> |
||||
</table> |
||||
<div class="margin_top_15px"> |
||||
<a id="fileUpload" class="hyperLink" href="<%=request.getContextPath()%>/fileupload.jsp">Back</a> |
||||
</div> |
||||
</div> |
||||
</body> |
||||
</html> |
@ -0,0 +1,73 @@
@@ -0,0 +1,73 @@
|
||||
* { |
||||
box-sizing: border-box; |
||||
} |
||||
|
||||
.margin_top_15px { |
||||
margin-top: 15px; |
||||
} |
||||
|
||||
.panel { |
||||
display: block; |
||||
padding: 15px; |
||||
border: 1px solid #c0c0c0; |
||||
width: 849px; |
||||
margin: 52px 0px 0px 32px; |
||||
} |
||||
|
||||
label { |
||||
display: inline-block; |
||||
margin-bottom: 5px; |
||||
} |
||||
|
||||
.form_group { |
||||
margin: 10px; |
||||
} |
||||
|
||||
.btn_primary { |
||||
color: #fff; |
||||
background-color: #0275d8; |
||||
border-color: #0275d8; |
||||
} |
||||
|
||||
.btn { |
||||
display: inline-block; |
||||
padding: 10px; |
||||
text-align: center; |
||||
white-space: nowrap; |
||||
vertical-align: middle; |
||||
cursor: pointer; |
||||
border: 1px solid transparent; |
||||
} |
||||
|
||||
.input_error { |
||||
color: #DE3330; |
||||
padding: 5px; |
||||
} |
||||
|
||||
.bordered_table { |
||||
border-collapse: collapse; |
||||
width: 100%; |
||||
table-layout: fixed; |
||||
} |
||||
|
||||
.bordered_table tr,th,td { |
||||
border: 1px solid #333; |
||||
} |
||||
|
||||
.bordered_table th,td { |
||||
padding: 5px; |
||||
} |
||||
|
||||
.bordered_table td { |
||||
word-wrap: break-word; |
||||
} |
||||
|
||||
#noFiles { |
||||
color: red; |
||||
font-size: larger; |
||||
} |
||||
|
||||
.hyperLink { |
||||
text-decoration: none; |
||||
cursor: pointer; |
||||
} |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,10 @@
@@ -0,0 +1,10 @@
|
||||
<!DOCTYPE web-app PUBLIC |
||||
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" |
||||
"http://java.sun.com/dtd/web-app_2_3.dtd" > |
||||
|
||||
<web-app> |
||||
<display-name>exchange-servlet</display-name> |
||||
<welcome-file-list> |
||||
<welcome-file>fileupload.jsp</welcome-file> |
||||
</welcome-file-list> |
||||
</web-app> |
@ -0,0 +1,42 @@
@@ -0,0 +1,42 @@
|
||||
<%@page import="java.util.List"%> |
||||
<%@page import="ru.molokoin.UploadDetail"%> |
||||
<%@page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> |
||||
<!DOCTYPE html> |
||||
<html> |
||||
<head> |
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> |
||||
<title>exchange-servlet</title> |
||||
|
||||
<link rel="stylesheet" href="resource/css/main.css" /> |
||||
</head> |
||||
<body> |
||||
<div class="panel"> |
||||
<h1>Uploaded Files</h1> |
||||
<table class="bordered_table"> |
||||
<thead> |
||||
<tr align="center"><th>File Name</th><th>File Size</th><th>Action</th></tr> |
||||
</thead> |
||||
<tbody> |
||||
<% List<UploadDetail> uploadDetails = (List<UploadDetail>)request.getAttribute("uploadedFiles"); |
||||
if(uploadDetails != null && uploadDetails.size() > 0) { |
||||
for(int i=0; i<uploadDetails.size(); i++) { |
||||
%> |
||||
<tr> |
||||
<td align="center"><span id="fileName"><%=uploadDetails.get(i).getFileName() %></span></td> |
||||
<td align="center"><span id="fileSize"><%=uploadDetails.get(i).getFileSize() %> KB</span></td> |
||||
<td align="center"><span id="fileDownload"><a id="downloadLink" class="hyperLink" href="<%=request.getContextPath()%>/downloadServlet?fileName=<%=uploadDetails.get(i).getFileName() %>">Download</a></span></td> |
||||
</tr> |
||||
<% } |
||||
} else { %> |
||||
<tr> |
||||
<td colspan="3" align="center"><span id="noFiles">No Files Uploaded.....!</span></td> |
||||
</tr> |
||||
<% } %> |
||||
</tbody> |
||||
</table> |
||||
<div class="margin_top_15px"> |
||||
<a id="fileUpload" class="hyperLink" href="<%=request.getContextPath()%>/fileupload.jsp">Back</a> |
||||
</div> |
||||
</div> |
||||
</body> |
||||
</html> |
@ -0,0 +1,29 @@
@@ -0,0 +1,29 @@
|
||||
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> |
||||
<!DOCTYPE html> |
||||
<html> |
||||
<head> |
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> |
||||
<title>exchange-servlet</title> |
||||
|
||||
<link rel="stylesheet" href="resource/css/main.css" /> |
||||
|
||||
</head> |
||||
<body> |
||||
<div class="panel"> |
||||
<h1>File Upload</h1> |
||||
<h3>Press 'CTRL' Key+Click On File To Select Multiple Files in Open Dialog</h3> |
||||
<form id="fileUploadForm" method="post" action="fileUploadServlet" enctype="multipart/form-data"> |
||||
<div class="form_group"> |
||||
<label>Upload File</label><span id="colon">: </span><input id="fileAttachment" type="file" name="fileUpload" multiple="multiple" /> |
||||
<span id="fileUploadErr">Please Upload A File!</span> |
||||
</div> |
||||
<button id="uploadBtn" type="submit" class="btn btn_primary">Upload</button> |
||||
</form> |
||||
</div> |
||||
|
||||
<!-- List All Uploaded Files --> |
||||
<div class="panel"> |
||||
<a id="allFiles" class="hyperLink" href="<%=request.getContextPath()%>/uploadedFilesServlet">List all uploaded files</a> |
||||
</div> |
||||
</body> |
||||
</html> |
@ -0,0 +1,37 @@
@@ -0,0 +1,37 @@
|
||||
<%@page import="java.util.List"%> |
||||
<%@page import="ru.molokoin.UploadDetail"%> |
||||
<%@page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> |
||||
<!DOCTYPE html> |
||||
<html> |
||||
<head> |
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> |
||||
<title>exchange-servlet</title> |
||||
|
||||
<link rel="stylesheet" href="resource/css/main.css" /> |
||||
</head> |
||||
<body> |
||||
<div class="panel"> |
||||
<h1>File Upload Status</h1> |
||||
<table class="bordered_table"> |
||||
<thead> |
||||
<tr align="center"><th>File Name</th><th>File Size</th><th>Upload Status</th><th>Action</th></tr> |
||||
</thead> |
||||
<tbody> |
||||
<% List<UploadDetail> uploadDetails = (List<UploadDetail>)request.getAttribute("uploadedFiles"); |
||||
for(int i=0; i<uploadDetails.size(); i++) { |
||||
%> |
||||
<tr> |
||||
<td align="center"><span id="fileName"><%=uploadDetails.get(i).getFileName() %></span></td> |
||||
<td align="center"><span id="fileSize"><%=uploadDetails.get(i).getFileSize() %> KB</span></td> |
||||
<td align="center"><span id="fileuploadStatus"><%=uploadDetails.get(i).getUploadStatus() %></span></td> |
||||
<td align="center"><span id="fileDownload"><a id="downloadLink" class="hyperLink" href="<%=request.getContextPath()%>/downloadServlet?fileName=<%=uploadDetails.get(i).getFileName() %>">Download</a></span></td> |
||||
</tr> |
||||
<% } %> |
||||
</tbody> |
||||
</table> |
||||
<div class="margin_top_15px"> |
||||
<a id="fileUpload" class="hyperLink" href="<%=request.getContextPath()%>/fileupload.jsp">Back</a> |
||||
</div> |
||||
</div> |
||||
</body> |
||||
</html> |
@ -0,0 +1,73 @@
@@ -0,0 +1,73 @@
|
||||
* { |
||||
box-sizing: border-box; |
||||
} |
||||
|
||||
.margin_top_15px { |
||||
margin-top: 15px; |
||||
} |
||||
|
||||
.panel { |
||||
display: block; |
||||
padding: 15px; |
||||
border: 1px solid #c0c0c0; |
||||
width: 849px; |
||||
margin: 52px 0px 0px 32px; |
||||
} |
||||
|
||||
label { |
||||
display: inline-block; |
||||
margin-bottom: 5px; |
||||
} |
||||
|
||||
.form_group { |
||||
margin: 10px; |
||||
} |
||||
|
||||
.btn_primary { |
||||
color: #fff; |
||||
background-color: #0275d8; |
||||
border-color: #0275d8; |
||||
} |
||||
|
||||
.btn { |
||||
display: inline-block; |
||||
padding: 10px; |
||||
text-align: center; |
||||
white-space: nowrap; |
||||
vertical-align: middle; |
||||
cursor: pointer; |
||||
border: 1px solid transparent; |
||||
} |
||||
|
||||
.input_error { |
||||
color: #DE3330; |
||||
padding: 5px; |
||||
} |
||||
|
||||
.bordered_table { |
||||
border-collapse: collapse; |
||||
width: 100%; |
||||
table-layout: fixed; |
||||
} |
||||
|
||||
.bordered_table tr,th,td { |
||||
border: 1px solid #333; |
||||
} |
||||
|
||||
.bordered_table th,td { |
||||
padding: 5px; |
||||
} |
||||
|
||||
.bordered_table td { |
||||
word-wrap: break-word; |
||||
} |
||||
|
||||
#noFiles { |
||||
color: red; |
||||
font-size: larger; |
||||
} |
||||
|
||||
.hyperLink { |
||||
text-decoration: none; |
||||
cursor: pointer; |
||||
} |
@ -0,0 +1,4 @@
@@ -0,0 +1,4 @@
|
||||
#Created by Apache Maven 3.8.5 |
||||
groupId=ru.molokoin |
||||
artifactId=exchange-servlet |
||||
version=0.1 |
@ -0,0 +1,4 @@
@@ -0,0 +1,4 @@
|
||||
ru\molokoin\FileUploadServlet.class |
||||
ru\molokoin\UploadDetail.class |
||||
ru\molokoin\FileDownloadServlet.class |
||||
ru\molokoin\UploadedFilesServlet.class |
@ -0,0 +1,4 @@
@@ -0,0 +1,4 @@
|
||||
c:\Users\Strannik\Documents\esoe\code\exchange-servlet\src\main\java\ru\molokoin\UploadDetail.java |
||||
c:\Users\Strannik\Documents\esoe\code\exchange-servlet\src\main\java\ru\molokoin\FileUploadServlet.java |
||||
c:\Users\Strannik\Documents\esoe\code\exchange-servlet\src\main\java\ru\molokoin\UploadedFilesServlet.java |
||||
c:\Users\Strannik\Documents\esoe\code\exchange-servlet\src\main\java\ru\molokoin\FileDownloadServlet.java |
Loading…
Reference in new issue