Send Request to server side [closed] - java

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'm developing a Java Desktop application with MySQL Database, I have searched the internet for days, i need to do the following:
(Client) Desktop application for client will have the GUI.
(Server) Tomcat Server With Servlet.
(Database) MySQL Database server.
Client send request for query in servlet, then servlet response to the client with result which will be filled in database.
No SQL Queries, Updates, Inserts, Delete ... etc will be exist on the client side, all will be in the servlets.
Is this the best way to make 3tier application?
Can I use Another idea or technology to achieve this?
I don't want to go for web application.
I need client send request to middle server, which will connect to database & getting the result then send them back to the client without letting the client connect directly to the database.
Note: The client will be used by Multiple users in same LAN.

A web application which is hosted on a server typically uses HTTP as the communication protocol. So if you want to build your GUI using Java then you will be sending http request on user actions and receiving http response which would be translated to updates on the GUI. You should perhaps use a library such as Apache HttpComponents to send/recieve http response. For creating/deploying a servlet web application you can find lots of tutorials. However these days people use MVC frameworks like Spring MVC ,Struts, JSF etc., as a web application framework which helps immensely in developing web applications.
As your requirement is that there should not be any SQL data access related code on your Client side, all the data access will need to be done on server side and your server side should send an accepted data format (xml/json) to your GUI in the http response which you will need to parse (there are many libraries to parse xml/json) and extract information from.
So your GUI will not be doing any resultset handling. It would be done by the server (inside web application) and the web application would send the xml/json response to your GUI request.
The architecture you are trying to develop in typical thin client architecture. You can imagine your Java GUI as a replacement for web browser.

Related

How to make proper server connection without storing client URLs on the server [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 3 months ago.
Improve this question
I am implementing a rather simple communicator - one broadcast chat and multiple others for private messaging between users/clients. The purpose of this app is educational and I want to use solutions that are (preferably:)) simple yet modern, flexible, and used in real life, I started implementation using RestController and I stored clients' URLs in the database but I quickly understood that this is not good practice. I want to ask about links and resources that may address the following questions:
How to make a flexible and secure connection between server and client without storing the latter URL?
What is the correct protocol for information exchange in this kind of application
One way to make a flexible and secure connection between a server and its clients without storing their URLs is to use WebSockets. WebSockets is a protocol that allows for full-duplex communication between a server and its clients. This means that the server and the clients can both send and receive messages at the same time, and the connection remains open until it is closed by one of the parties.
Using WebSockets, the server can send messages to specific clients or broadcast messages to all connected clients. This allows for both private messaging and broadcast chat functionality in your application.
You can use a WebSockets library such as Socket.io for Java (https://github.com/socketio/socket.io-client-java). This library makes it easy to set up WebSockets on the server and handle incoming and outgoing messages from clients.
Some resources that may be helpful for learning more about WebSockets and implementing:
The WebSockets API: https://developer.mozilla.org/en-US/docs/Web/API/WebSockets_API
Socket.io: https://socket.io/
A tutorial on using Socket.io for real-time communication: https://socket.io/get-started/chat/

Creation of a client-server desktop application [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 6 years ago.
Improve this question
I've in the past created client-server web applications using Javascript, AJAX, Node, Express and MongoDB, but now I'm required to creare a client-server desktop application. It will therefore basically consists of a desktop program which will connect to a server program by doing requests. The server program will respond to the client program with the requested data which it can fetch from the database.
Since I'm really new to these kind of applications in Java, I have no idea how to create such an application in Java. Since the project will be large, we cannot hard-code all the server. We need probably a framework on the server side that listens for requests, but I've not found any for now. For example, Play Framework seems only to work for web applications. Which frameworks are useful for these purpose? Is this the right approach for this kind of applications? How would I connect client and server applications?
Please, do not suggest "use sockets". This will be quite a big "serious" project, and we need high level tools. We don't know how usually these kind of projects are created. Please, explain a little bit which patterns are usually used. Examples of concrete programs, maybe with open source code will be useful for us to understand. Also a list of the requirements that we need for these project would be very useful.
Note: I'm not asking for a exhaustive list of frameworks that we can use. I rather asking which kind of tools (with concrete examples) should we use and how to combine them. How to structure such a project.
You could write the server side application in Node JS or whatever other server side language you prefer - and implement that using REST services. Then in your Java desktop application, it would just communicate with the server using HTTP REST / SOAP etc.
That way if you were to then want to swap to use something like .NET to make your desktop application you would be free to do so without it changing anything on the server side. Also you would be able to implement a mobile application / tablet app / other web application and reuse all of the server side implementation easily without changing anything server side.
Another option is to use ServerSocket for the Java server side, and then connect to that from the client but you seem to know and dislike that option.
Another option to connect each side of the application would be to use some kind of pub / sub middleware messaging service - check out JMS as a framework - you will need some kind of implementation of JMS such as Active MQ, Websphere MQ or one of the many other free implementations. Check out : http://docs.oracle.com/javaee/6/tutorial/doc/bncdq.html
Difficult question to answer, but those are 3 high level options.
Use web technologies to connect client to server HTTP REST, or SOAP
Use ServerSockets and Socket connections and do everything manually
Use a messaging framework such as JMS

How to sync data from a local database to a remote database [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 have a java application that collects data (such as login user, logon time, ...) into a local database (probably a Derby database or similar). This application will run on several PCs (windows XP, 7 ...). I would like to collect all data from each PC and save into a main database that reside on a remote server. Then a web application could display the results and statistics for all PCs. The local database is important as we need to collect data even if the link to the main servers database is down.
I would like to be able to push the data from each PCs to the main database. (notice that this ideas come from the splunk application where log entries are push from local applications to a main server).
How can the java application of each PCs communicate with the main database. Any good examples are welcomed?
Is it possible to use some HTTP request (json or rest) from the local java application to send the data? If so, how can this be done (examples)? What is needed on the local PCs to accomplish this?
Any better ideas or suggestion are welcomed.
How can the java application of each PCs communicate with the main
database.
Whatever method you're using to communicate with your derby database will be the same to communicate with your remote database. Typically this would be done with JPA or Hibernate or a similar ORM library.
See: http://docs.oracle.com/javaee/6/tutorial/doc/bnbpz.html
Is it possible to use some HTTP request (json or rest) from the local
java application to send the data? If so, how can this be done
(examples)? What is needed on the local PCs to accomplish this?
For this you'd want to investigate JAX-RS which is the java standard way of communicating with restful web services.
See: https://jersey.java.net/documentation/latest/client.html

Webservice to show Java frame [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 8 years ago.
Improve this question
I need some suggestions if the below idea for my web-service is feasible and if so, some pointers on how to implement the same.
Web-service Request: Request number
Web-service response: Java Jframe popup on users desktop with details of the request queried from the database.
This web-service would get triggered by clicking on an hyper-link in email notification sent to the user.
I cannot write any code on the client side to read the web-service response and then populate the Java frame.
So is it possible for my web-service to pop-up the JFrame on the users desktop when they query the web-service?
If so, how would I configure my response in the WSDL?
The web service runs on the server, the JFrame would run inside a different JVM on the client. So no, the web service can't trigger a JFrame to be shown on the client.
In fact, the web service can't force the client to do anything whatsoever. What the client does with whatever information the web service provides it is totally up to the client, which can be anything, from a Java Swing application (which could use it to display something in a JFrame) to another web service written in Perl (which would likely use it as input for another call or response to something) to an ASP web application (which might display it on a website as a graphic or table of data), to an Oracle SQL query (which may use the result to enter data into a database table which might in turn trigger something else to send an email for example).
That's the very nature of web services, they're utterly agnostic of what and who calls them.

proxy server configuration [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
I am assigned to implement (or better configure) a kind of http proxy server. The server should support processes like described below:
-A user opens an URL in his browser which has the following structure: http://:/resource_name
-Proxy server validates the resource name in the URL of the incoming http-request and determines the URL of a web-resource it should forward the original request from the client to
-Proxy server forwards the original request, waits until it gets an answer from the external web-server, and posts it back to the user
I'm working within java, but I wouldn't like to implement a proxy server by myself playing with sockets. Instead I'd like to use an apache http server. Does anybody know if its possible to accomplish such a task on the configuration level using apache http server? If so, how?
Thank you in advance for your answers!
You can do this in Apache using the modules mod_proxy (to proxy your requests forward) and mod_rewrite (to map your external URL to the URL on your application server)
http://httpd.apache.org/docs/2.0/mod/mod_proxy.html
http://httpd.apache.org/docs/current/mod/mod_rewrite.html
Apache is not written in java. Your chances are good with Tomcat or Jetty.
You will need to implement a webapp with a Servlet intercepting all requests and then handle all your custom logic in the Servlet.

Categories

Resources