Saturday, 11 November 2017

HTTP Response Statuses

2xx (Success category)

These status codes represent that the requested action was received and successfully processed by the server.
  • 200 Ok The standard HTTP response representing success for GET, PUT or POST.
  • 201 Created This status code should be returned whenever the new instance is created. E.g on creating a new instance, using POST method, should always return 201 status code.
  • 204 No Content represents the request is successfully processed, but has not returned any content.
    DELETE can be a good example of this.
    The API DELETE /companies/43/employees/2 will delete the employee 2 and in return we do not need any data in the response body of the API, as we explicitly asked the system to delete. If there is any error, like if employee 2 does not exist in the database, then the response code would be not be of 2xx Success Category but around 4xx Client Error category.

3xx (Redirection Category)

  • 304 Not Modified indicates that the client has the response already in its cache. And hence there is no need to transfer the same data again.

4xx (Client Error Category)

These status codes represent that the client has raised a faulty request.
  • 400 Bad Request indicates that the request by the client was not processed, as the server could not understand what the client is asking for.
  • 401 Unauthorized indicates that the client is not allowed to access resources, and should re-request with the required credentials.
  • 403 Forbidden indicates that the request is valid and the client is authenticated, but the client is not allowed access the page or resource for any reason. E.g sometimes the authorized client is not allowed to access the directory on the server.
  • 404 Not Found indicates that the requested resource is not available now.
  • 410 Gone indicates that the requested resource is no longer available which has been intentionally moved.

5xx (Server Error Category)

  • 500 Internal Server Error indicates that the request is valid, but the server is totally confused and the server is asked to serve some unexpected condition.
  • 503 Service Unavailable indicates that the server is down or unavailable to receive and process the request. Mostly if the server is undergoing maintenance.

Wednesday, 16 August 2017

RESTful JAX-RS Annotations


@Path
It identifies the URI path. It can be specified on class or method.

@PathParam
represents the parameter of the URI path.

@GET
specifies method responds to GET request.

@POST
specifies method responds to POST request.

@PUT
specifies method responds to PUT request.

@HEAD
specifies method responds to HEAD request.

@DELETE
specifies method responds to DELETE request.

@OPTIONS
specifies method responds to OPTIONS request.

@FormParam
represents the parameter of the form.

@QueryParam
represents the parameter of the query string of an URL.

@HeaderParam
represents the parameter of the header.

@CookieParam
represents the parameter of the cookie.

@Produces
defines a media type for the response such as XML, PLAIN, JSON etc. It defines the media type that the methods of a resource class or MessageBodyWriter can produce.

@Consumes
It defines the media type that the methods of a resource class or MessageBodyReader can produce.

Sunday, 12 February 2017

What does “use strict” do in JavaScript

"use strict" is to indicate that the code should be executed in "strict mode"

Now What is "strict mode"

Strict mode makes it easier to write "secure" JavaScript.
Strict mode changes previously accepted "bad syntax" into real errors.

x = 3.14;       // This will not cause an error. myFunction();

function myFunction() {
   "use strict";
    y = 3.14;   // This will cause an error}
Try it Yourself »


"use strict" is used at global scope or in scope of function 


x = 3.14;       // This will not cause an error. myFunction();

function myFunction() {
   "use strict";
    y = 3.14;   // This will cause an error}
Try it Yourself »

Wednesday, 3 February 2016

Publish node module to access by NPM command

Publishing public node module is easy process like some command and you have it

  • create directory "demo-example-package"
  • cd demo-example-package
  • npm init 
    • type module name, description, version, author, entry point,etc.. 
  • create file index.js which is entry point of your module

I share one example module on https://www.npmjs.com/package/n-random, take it as example and right yout own code in to index.js and your have your module ready to go.

now publish this by : npm publish 

you can simply import your module by npm command like as like as other module.

npm install demo-example-package

for more information you can refer youtube video : https://www.youtube.com/watch?v=3I78ELjTzlQ  





Angularjs - RequreJS - Lazy loading Template for beginner


Simply install Node.js : https://nodejs.org/en/download/

install Git  : https://git-scm.com/downloads

clone seed project from 

https://github.com/mastermoin/angular-require-seed

run project by command

npm start

type url on browser : http://localhost:8000/app/#/view1 

Please read more about it on GIT repository home page 

Tuesday, 26 January 2016

HTML5 set responsive background image


CSS
_______________________________________________________

       html, body {
            margin: 0;
            padding: 0;
            color: white;
            height: 100%;
            text-align: center;
        }

        #background {
            background: #000000 url('image/bg.jpeg') no-repeat bottom left;
            background-size: 100% 100%;
            width: 100%;
            height: auto !important;
        }


HTML
_______________________________________________________

<htlm>
      <body id="background">
      </body>
</html>