Java tutorial
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package servlets; import java.io.File; import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.dom4j.Document; import org.dom4j.DocumentException; import org.dom4j.Element; import org.dom4j.io.SAXReader; import org.xml.sax.ErrorHandler; /** * * @author ilir */ @WebServlet("/LoaderSoa10g") public class LoaderSoa10g extends HttpServlet { private static final long serialVersionUID = 123L; @Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { System.out.println("Ciauz"); String path = request.getParameter("indirizzo").trim(); File dir = new File(path); File[] directoryListing = dir.listFiles(); if (directoryListing != null) { for (File child : directoryListing) { try { SAXReader reader = new SAXReader(); reader.setValidation(false); Document document = reader.read(path + "/" + child.getName()); Element root = document.getRootElement(); System.out.println(root.getNamespace()); } catch (DocumentException e) { e.printStackTrace(); } } } else { // Handle the case where dir is not really a directory. // Checking dir.isDirectry() above would not be sufficient // to avoid race conditions with another process that deletes // directories. } } @Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { doGet(request, response); } }