Now we know how to create a web app using servlet classes. We know how to get user input, how to access a database, and how to handle user logins. But what if we want to support different kinds of programs instead of just a web app? What if we want to create a desktop application or an Android app? How do we provide access to our data for those programs without writing everything from scratch each time?
One of the nice things about a REST API is that theyâre pretty language-agnostic. Once you have one in place, you can interact with it by sending HTTP requests from whatever language you want.
Iâd recommend googling something like âJava send http requestâ for a bunch of results! You might also be able to find a library that handles a lot of the details for you. Good luck!
Hi,
From where did the âtokenâ variable appear as it has not been declared in the âlogin()â function, and also it is been used in the âsetPersonInfo()â and âgetPersonInfo()â functions without being declared prior. Overall how is the token stored in the clientâs web browser?
Thank you.
If youâre asking about the JavaScript code, the token variable is declared as a global variable, so it can be accessed by every function after itâs set.
The btoa() function is a standard JavaScript function. Iâd start by googling âJavaScript btoaâ for some references!
Oh i see thanks , and also if we want the user to be able to make requests from other pages do we then store the token value in a cookie or something like that since other pags wont have the token value?
P.S Your tutorials are amazing
And thank you very much! These Java server tutorials are getting a little stale, so Iâve been working through updating them. Hopefully Iâll be able to update this tutorial soon!