Menu



How to create folder or directory in sever JSP


index.html

<!DOCTYPE html>
<html>
<body>
<form action="CreateFolder.jsp" method="post">
<h2>
Create New Folder
</h2>
<input name="createfolder" type="text">
<input type="submit" value="Create Folder">
</form>
</body>
</html>

CreateFolder.jsp

<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<%@page import="java.io.File"%>
<%
String createfolder = request.getParameter("createfolder");
String path = "C:/temp/data/" + createfolder;
File f = new File(path);
if(!f.exists()){
if(f.mkdirs()){%>
<h2>created file <%=createfolder%></h2>
<%}
}
%>