0

i'm using intellij for developing my web application using boilerpipe jar to create an application like this,but i'm getting error in instantiating servlet class .. this is my servlet code

import de.l3s.boilerpipe.BoilerpipeProcessingException;
import de.l3s.boilerpipe.extractors.ArticleExtractor;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.logging.Logger;


public class Servlet extends HttpServlet {

    private final static Logger LOGGER  = Logger.getLogger(Servlet.class.getName());



    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {


        try {

            String urlString = "http://commercialobserver.com/2014/06/50102-sf-mixed-use-building-planned-for-east-harlem/";
            PrintWriter writer = response.getWriter();
            URL url = new URL(urlString);
            String article = ArticleExtractor.INSTANCE.getText(url);
            writer.println(article);
            LOGGER.info("Content extracted successfully ");
            writer.close();

        } catch (MalformedURLException e) {
            LOGGER.severe("Exception thrown for invalid url " + e);
        } catch (BoilerpipeProcessingException e) {
            LOGGER.severe("Exception thrown during scraping process " + e);
        } catch (IOException e) {
            LOGGER.severe("Exception thrown" + e);
        }
    }
}
Halvor Holsten Strand
  • 19,829
  • 17
  • 83
  • 99
ashif-ismail
  • 1,037
  • 17
  • 34

0 Answers0