2
package com.index;

import java.net.URL;

import com.opensymphony.xwork2.ActionSupport;
import de.l3s.boilerpipe.extractors.ArticleExtractor;

public class search_article extends ActionSupport {
/**
 * 
 */
private static final long serialVersionUID = 1L;
String article;

public String getArticle() {
    return article;
}

public void setArticle(String article) {
    this.article = article;
}

@Override
public String execute() throws Exception {

    String content = null;
    URL url = new URL("http://www.nydailynews.com/sports/baseball");
    ArticleExtractor ae = new ArticleExtractor();
    content = ae.getText(url);
    System.out.println(content);
    System.out.println("in execute");
    return SUCCESS;
}
 }

It Shows following error : HTTP Status 500 - java.lang.reflect.InvocationTargetException

Paul Lo
  • 6,032
  • 6
  • 31
  • 36
  • That's a server error. Either your request isn't what the server expects, or there's a server issue. Not sure what you'd like help with. – Dave Newton Jan 16 '14 at 15:56
  • what is `SUCCESS` in your `execute()` method? I don't see it defined anywhere... – SnakeDoc Sep 22 '14 at 21:12
  • Also, the URL you have pointed at is not an article, but rather a category page... try pointing at an actual article and see what happens... – SnakeDoc Sep 22 '14 at 21:14

1 Answers1

0

An HTTP error of 500 to 599 (although only very few numbers are actually used) is different from the more known 4xx errors.

The 4xx errors indicate that YOU as the client have done something wrong and you should modify your request, so that the server can fulfill ist - the most prominent error is 404 web page not found (more precise object not found).

A 5xx error on the other hand indicates a server error. That means, you probably did everything right, but the server is unable to handle your request.

With 4xx errors you could continue issuing your request till the end of all days, it won't work. With 5xx errors it could, at some point, work - examples include heavy load on the server typically resulting in a 500 (internal server error).

siliconchris
  • 613
  • 2
  • 9
  • 22
  • how does this actually answer the question? this should be a comment, not an answer. – benka Sep 22 '14 at 10:50
  • you are right. I think I misplaced this. But in a sense, it does answer his question in such that he probably does not really have a problem. Anyway, will try to avoid this in the future – siliconchris Sep 22 '14 at 21:04