I want to create an XML file through servlet Here is my code
out.println("<html>") out.println("<head>");
out.println("<title>Servlet contactReq</title>");
out.println("</head>");
out.println("<body>");
//PrintWriter out = response.getWriter();
//System.out.println("Hello you are in get method");
String fName = request.getParameter("firstName");
String lName = request.getParameter("lastName");
String email = request.getParameter("email");
int phNo = Integer.parseInt(request.getParameter("phoneNo"));
add(fName,lName,email,phNo,response);
out.println("<h1>Successssssssss :"+fName+"</h1>");
out.println("</body>");
out.println("</html>");`
In add()
I used this
File f = new File("src"+File.separator+"xmlparse");
f.createNewFile();//create the file
out.println("<h2>Root:"+f.getAbsolutePath()+"</h2>");
but I didn't get this root :.....
, my file was not created and if I want to write logic in servlet. Is this the proper way?