java - Is there any built in class with HTTP response codes and its categories? -


When I'm one of the code's success codes (2xx), I usually make an integer array and its For example, look for the medium, for example, public static final integer [] SUCCESS_STATUS_CODES = new int [] {200, 201, 202, 203, 204, 205, 206, 207, 208, 226} ;

I do the same for other feedback codes.

I was wondering if there is an underlying object that already keeps all of these codes and regularly updates what I can use?

For example,

  // pseudo code if (responsecode is from success 2xx category) do something else (the response code is from the error 4xx category   

As far as I know, there is no such class in the standard library. That's if is java.net.HttpURLConnection , which provides constant constants for different codes.

But you feel that you need to do more work HTTP response code categories are created in their values, you should be able to do something with these lines: / p>

  switch (response code / 100) {Case 1: / * Informational response * / Case 2: / * Success Response * / Pause; Case 3: / * Redirection Response * / Pause; Case 4: / * Client Error Response * / Brake; Case 5: / * Server Error Response * / Brake; Defaul T : / * Bad response Or code * / break;}    

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -