Server to Server communication using servlet? [closed] - java

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
In my case there is a cloud server and personal application server.
I have to make a communication between both servers for accessing the data periodically.
How to create api for communication using servlet.
Is possible to use timer in servlet?
Any other suggestions?
Thanks in advance.

Yes, you can user a timer within a servlet, but as Stanley suggested, web services is a layer on top of http that you can use and it may be easier.
If you just need some quick and dirty way, you can write a servlet to receive the http request in one end and some http client to do the request.
If you go Java EE, it's even easier because you can generate web services using annotations and there's already a TimerService so you won't have to reinvent the wheel.

Related

How can I integrate an API from a website in Java? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 1 year ago.
Improve this question
My question is very concise. I have an API from RapidApi and I am looking to make a interactive Web Application. How can I integrate the API into Java in order to get access to all the methods that the API provides? Thank you.
The API will most probably be a REST API. Have a look at https://restfulapi.net/ for background info.
The process of interacting with a REST API is called "consuming" the API.
Basically you just launch a HTTP request to the API, and the result is a JSON data structure.
The details of the HTTP Requests (URL, HTTP methods to use, and data to send), and the JSON return format are documented by the API.
Although it can be done without using any specific framework, it is probably easier with a framework like Spring.
If you know the basic concepts of Spring you could follow one of their guides about this topic: https://spring.io/guides/gs/consuming-rest/

Codename One Sockets Send Message to Client [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
i want to write a simple App for me (Android). For this it is necessary that the server can send data to my client (only one client at a time) but unfortunately i have no idea how to use sockets or websockets with codename one.
Can someone please post a small examplecode how to establish connection, listen on it and send some small data?
greetings
Captain
You need to use the cn1lib from Steve Hannah to access websockets. Its available here: https://github.com/shannah/cn1-websockets
Found thru looking at https://www.codenameone.com/cn1libs.html
Sockets are a bit problematic though, you might want to look at push, pubnub or just https if applicable. See the chat app demo parts 5 & 6 for the former:
https://www.codenameone.com/blog/building-a-chat-app-with-codename-one-part-5.html
have a look at this example code: https://towhidz.wordpress.com/2012/03/03/simple-chat-applicationclient-server-in-android/
Google is your friend

how to create application layer (server ) in java [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I am building an android app and i have following doubts:-
I need help in how to create back end that is server (application layer).(I am good in java . so if you could guide me a way using java that would be nice)
I need know how to connect the server to my app both on app and on server side.
It depends on you're needs but you're best bet is using something like Django, Ruby on Rails or Python.
Building Awesome Rails API's Part 1
If you want to use Java, there are more ways. Here is one of them (pretty common these days). Your backend app could be a spring based and use REST controllers as the endpoints. There are plenty of introductions, e.g. http://spring.io/guides/gs/rest-service . Once you have established and run the backend app (either deployment to a web server or spring boot - see http://spring.io/guides/gs/spring-boot/) you can connect to the server via TCP/IP. Your android app could use http-client.

Java back-end and JavaScript front-end, how to join? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
I'm new to creating a web application with a Java back-end and a JavaScript, HTML 5 front-end. How do I pass content between the two?
You are looking for a web framework. These will integrate all three technologies you mention into a server and fully functioning webapp. You will also need to be working with JavaEE.
I recommend Jetty or Play
Look up some tutorials on how to get started but basically these frameworks will create the server backend that launches on a port and can host different sockets etc... and since theyre in Java the backend code can literally be written anywhere in the project...front end is easy too, you'll see how it works once you work through your first tutorial with them :)
Java EE is what you need indeed.
on a back end you add end points, and on front end you hit those end points w/ ajax

What do you think if I use JAX-RS to implement Web Apps (vs Web Services)? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
I like the way JAX-RS represent URLs.. and find it very easy to be used.
I am thinking of making the JAX-RS works instead of my Servlets, so I can write some JSPs that interact directly with these RESTful resources ...
What do you think?
It's not a decision about your model programming, is a decision about architecture and requirements of your application.
My first experience with JAX-RS was very positive. I used the framework to provide some server side functionality to a desktop app. But I wouldn't see the value of using REST if you are creating a traditional Web app where each client action results in a new Web page getting loaded by the user's browser. If you are building an AJAX app, then I can see how REST might be cleaner to code than Servlet.
What is the nature of the project?
Actually it doesn't matter servlets or even use PHP/HTML front end as you JAX-RS use HTTP request. I would suggest you to use JAX-RS reference implementation for building RESTful Web services call jersey. It provide more goodies ..

Categories

Resources