title: Best approach to extend a class functionality in java?
body: <p>for short, this could be paraphrased like "inheritance versus function library"</p>
  
  <p>for example, I'd like to add a method to the javax.servlet.http.HttpServletRequest that gives me the whole body, a getBody() method that would read the body thru the getReader method, just to put an example.</p>
  
  <p>In other languages, like ruby or javascript, you could add a method to the base class, or even to a specific instance, but in java I see this two choices...</p>
  
  <ol>
  <li><p>extend HttpServletRequest ( something like MyHttpServletRequest) and add the method</p></li>
  <li><p>or create an HttpServeletHelper static class, with static methods, with the following method</p></li>
  </ol>
  
  <p>public static String HttpServeletHelper.getBody( HttpServletRequest request )</p>
  
  <p>the first approach is more object oriented, and elegant, but forces you to cast your object every time you need it, and somehow you have to tell jsp to use your class...</p>
  
  <p>the second approach is just a good old function library... which might be a good or bad thing depending on how you look at it...</p>
  
  <p>what pros / cons do you see in each approach, and which one is the more recommended for this kind of situations?</p>