简体   繁体   中英

Do we really need a rest java client or we can directly fire rest request from HTML page

I am completely new to this topic. I have got a server application on which I have to hit a REST request.

Now should it be done directly from HTML file or I need to implement a Java client (like Jersey client) to forward my REST request.

Which one is more useful and for what scenarios?

One of the simplest of browser based REST client is :

Chrome REST client https://chrome.google.com/webstore/detail/advanced-rest-client/hgmloofddffdnphfgcellkdfbfbjeloo

You can use "curl" if you are on unix systems. for example to fire http GET request you can execute following command -

curl -X GET " http://google.com "

to get verbose output you can use "-v" to add headers you can use "--header"

similarly to post data to server

curl -X POST " http://google.com/answers " --data "a=b;c=d"

If you want to use browser to make REST calls you can use following plugin for chrome -

chrome://restclient/content/restclient.html

Similary plugins can be found for other browsers. Which one is better ? depends on your need. If you are just testing and if you don't like command line so much then, you can use chrome plugin but then you can't write script around it which you can do with curl.

REST services can be best hit just by HTTP Clients - browsers, You can use Java script ajax to hit them as well. There are also clients available in Java, PHP as well but they all essentially do the same thing that is hit an HTTP/S URL with a specific method (GET/POST/PUT/DELETE) requesting a specific content type like JSON, XML, RSS, etc.

curl is nice. On Windows I sometimes use this https://code.google.com/p/rest-client/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM