I have an HTML page that takes text input of the file path and that input process by the getOwner() of a Detail class in servlet. This servlet creates an HTML dropdown menu with all the local users in a computer fetched from the getACL() in the same servlet. Now if a user selects a specific user and the checkbox having different permission, how to get the selected value in the dropdown menu and checkbox to be processed by modifyACL() in Detail class.
public class Details {
native String[] getACL(String s);
native String getOwner(String name);
native void modifyACL(String s, String k, int i);
static{
System.loadLibrary("Details");
}}
Servlet class
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class ACL extends HttpServlet{
private static final long serialVersionUID = 1L;
public void doGet(HttpServletRequest req,HttpServletResponse res)throws ServletException,IOException
{
Details obj =new Details();
int len;
System.load("C:\\Users\\pradeep-pt3689\\eclipse-workspace\\FilePermission\\jni\\Details.dll");
String pathDir = req.getParameter("path");
res.setContentType("text/html");//setting the content type
PrintWriter pw=res.getWriter();//get the stream to write the data
pw.println("<html><body><center>");
pw.println("Welcome to servlet,File owner is: <b>");
pw.println(obj.getOwner(pathDir));
pw.println("</b><br><br>");
String[] prop = obj.getACL(pathDir);
pw.println("The File property is ::<br><table><tr><th>User or Group Name</th><th>Permission</th></tr>");
len=prop.length;
String[] arr = new String[len];
for(int i=0;i<len;i++)
{
String[] parts=prop[i].split("\\\\");
arr[i]=parts[0]+"\\"+parts[1];
pw.println("<tr><td>");
pw.println(arr[i]);
pw.println("</td><td>");
if(parts[2].contains("Full Control"))
{
pw.println("<label><input type='checkbox' name='property' value='FullControl' checked='checked'/>Full Control</label>"
+ "<label><input type='checkbox' name='property' value='Read'/>Read</label>"
+ "<label><input type='checkbox' name='property' value='Write'/>Write</label>"
+ "<label><input type='checkbox' name='property' value='Execute'/>Execute</label>");
}
else
{
pw.println("<label><input type='checkbox' name='property' value='FullControl'/>Full Control</label>");
if(parts[2].contains("Read")){
pw.println("<label><input type='checkbox' name='property' value='Read' checked='checked'/>Read</label>");
}
if(parts[2].contains("Execute")) {
pw.println("<label><input type='checkbox' name='property' value='Read' checked='checked'/>Execute</label>");
}
if(parts[2].contains("Write")) {
pw.println("<label><input type='checkbox' name='property' value='Read' checked='checked'/>Write</label>");
}
}
pw.println("<td></tr>");
}
pw.println("</table>");
pw.println("<hr>");
pw.println("Enter details to modify ACL<br><br>");
pw.println("<label for='user'>Select a user:</label><select name='user'>");
for(int j=0;j<len;j++) {
pw.println("<option value='");
pw.println(arr[j]);
pw.println("'>");
pw.println(arr[j]);
pw.println("</option>");
}
pw.println("</select> ");
pw.println("<label><input type='checkbox' name='modifyProperty' value='FullControl' checked='checked'/>Full Control</label>"
+ "<label><input type='checkbox' name='modifyProperty' value='Read'/>Read</label>"
+ "<label><input type='checkbox' name='modifyProperty' value='Write'/>Write</label>"
+ "<label><input type='checkbox' name='modifyProperty' value='Execute'/>Execute</label>");
pw.println("</center></body></html>");
pw.close();//closing the stream
}
}
I have to get selected value of second part in given page image.