title: Request web Page on Glassfish server using java code
body: <p>am trying to read web page from java code and its fine for general web site like google.com but when using the same code to read page on glassfish server at my computer i have this error:-</p>
  
  <pre><code>java.io.IOException: Server returned HTTP response code: 406 for URL: http://jedsms02:8080/Mirnint_Library-Mirnint_Message-context-root/Sending.jsp
  at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1436)
  at java.net.URL.openStream(URL.java:1010)
  at reader.ReadSMS.main(ReadSMS.java:195)
  </code></pre>
  
  <p>and this is my code:-</p>
  
  <pre><code>String urlString =
         "http://localhost:8080/Mirnint_Library-Mirnint_Message-context-root/Sending.jsp"
      try {
          URL url;
          url = new URL(urlString);            
          Scanner in = new Scanner(url.openStream());
          while (in.hasNext())
              System.out.println(in.nextLine());
      } catch (MalformedURLException e) {
          e.printStackTrace();
      } catch (IOException e) {
          e.printStackTrace();
      }
  </code></pre>
  
  <p>I had change the URL by replace the localhost to IP "192.120.20.167" but i get this error</p>
  
  <pre><code>java.io.IOException: Server returned HTTP response code: 505 for URL: http://192.120.20.167:8080/Mirnint_Library-Mirnint_Message-context-root/Sending.jsp?Number=0xxxxxxxxx&amp;Message= Test Man
  at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1436)
  at java.net.URL.openStream(URL.java:1010)
  at reader.ReadSMS.main(ReadSMS.java:195)
  </code></pre>
  
  <p>Please help,
  thank you</p>