[英]User can create file or folder but restricted to delete in centos-8
[英]Create a user in centos 5 from a jsp form
我有一個表單,該表單通過郵寄方法發送registration.jsp文件,該文件首先保存在數據庫中,然后必須打開“ command.sh”:
<%@ page import ="java.sql.*,java.io.*"%>
<%
String user = request.getParameter("uname");
String pwd = request.getParameter("pass");
Class.forName("com.mysql.jdbc.Driver");
Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/jsp",
"root", "");
Statement st = con.createStatement();
int i = st.executeUpdate("insert into members(uname, pass, regdate) values ('" + user + "','" + pwd + "', CURDATE())");
Process p=Runtime.getRuntime().exec("./command.sh "+user+pwd);
if (i > 0) {
response.sendRedirect("welcome.jsp");
} else {
response.sendRedirect("index.jsp");
}
我正在使用以下代碼,但是在運行它時出現錯誤:
是的,保存在數據庫中。 我還不知道如何通過接收從jsp發送的數據來創建Unix用戶。
請幫我
嘗試使用ServletContext.getRealPath()
,例如:
String fullPath = application.getRealPath("command.sh");
String[] cmd = { fullPath + " " + user + pwd };
Process p = Runtime.getRuntime().exec(cmd);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.