<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page import="java.io.*" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme() + "://"
+ request.getServerName() + ":" + request.getServerPort()
+ path + "/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'createD.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head>
<body>
<%
String pathStr = request.getRealPath("/upload");
pathStr = pathStr + "\\Sub";//將要建立的目錄路徑
out.println(pathStr);
//建立代表Sub目錄的File對象,并得到它的一個引用
File d = new File(pathStr);
if (d.exists()) {//檢查Sub目錄是否存在
d.delete();
out.println("Sub目錄存在,已刪除");
} else {
d.mkdir();//建立Sub目錄
out.println("Sub目錄不存在,已建立");
}
%>
</body>
</html>