title: Is there a way to print the content from the API to the localhost server?
body: <p>I'm trying to learn spring and at the same time build a small project and I encountered a problem. Everything works as it should, but I can't figure out how to make use of the API's method content that is printed in my Eclipse Console.</p>
  <p>In my controller I have all the information required to use the specific method of the API. I mapped the URL using <strong>&quot;@GetMapping(&quot;/seasons&quot;)</strong> and I'm using a code snippet from an online API(with key). And in the VIEW folder(basically where I keep the JSP files, example: seasons.jsp) I am trying to retrieve data from the response of the API.</p>
  <p>This is the response of the API: &quot;<code>{&quot;get&quot;:&quot;seasons&quot;,&quot;parameters&quot;:[],&quot;errors&quot;:[],&quot;results&quot;:10,&quot;response&quot;:[2012,2013,2014,2015,2016,2017,2018,2019,2020,2021]}</code>&quot;</p>
  <p>UPDATE:</p>
  <p>Here is some code for refference:</p>
  <pre><code>    @GetMapping(&quot;/seasons&quot;)
  public String seasons(Model theModel) throws IOException, InterruptedException {
      List&lt;Integer&gt; SeasonsList = new ArrayList&lt;&gt;();
  
      HttpRequest request = HttpRequest.newBuilder()
              .uri(URI.create(&quot;https://api-formula-1.p.rapidapi.com/seasons&quot;))
              .header(&quot;x-rapidapi-host&quot;, &quot;api-formula-1.p.rapidapi.com&quot;)
              .header(&quot;x-rapidapi-key&quot;, &quot;5a6f44fa10msh40be2be8d20bc5bp18a190jsnb4478dcbc8f1&quot;)
              .method(&quot;GET&quot;, HttpRequest.BodyPublishers.noBody())
              .build();
      HttpResponse&lt;String&gt; response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
      
      JSONObject seasonsObject = new JSONObject(response.body());
      for(int i = 0; i &lt; seasonsObject.length(); i++) {
          JSONArray object = seasonsObject.getJSONArray(&quot;response&quot;);
          for(int j = 0 ; i &lt; object.length(); j++) {
              SeasonsList.add(object.getInt(j));
              
          }
          System.out.println(object);
      }
      
      theModel.addAttribute(&quot;theSeasons&quot;, SeasonsList);
      return &quot;seasons&quot;;
  }
  </code></pre>
  <p>And the HTML file:</p>
  <pre><code>&lt;html xmlns:th =&quot;http://www.thymeleaf.org&quot;&gt;
  &lt;head&gt;
  
  
  &lt;title&gt;The Formula 1 Seasons are&lt;/title&gt;
  
  
  &lt;/head&gt;
  
  &lt;body&gt;
   &lt;p th:text =&quot;'The seasons are:  ' + ${theSeasons}&quot;/&gt;
  
  &lt;/body&gt;
  
  
  &lt;/html&gt;
  </code></pre>
  <p>The thing that I want is to show  &quot;The seasons are : 2012, 2013, 2014..etc.</p>
  <p><strong>And I get an error in console : &quot;org.json.JSONException: JSONArray[10] not found.&quot;</strong></p>
  <p>Please let me know if you need any detail from my project.</p>