Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I want to code a java program which must be able to communicate with web browsers (the clients). Sending data / answering requests is not a problem but I also want to send new data to the clients (so that they see it in their browsers without reloading the page).
What ways are there to accomplish that?
Is there any way to listen for new data (with JavaScript)?
i think what you are talking about is server push.
ie server will send data to client without polling from client.
There are various ways to do this one of the best way is through websockets.
you can use many java server available for websockets and have connect client for asynchronous push. while at client normal javascript will be able to receive the message.
What you're trying to do is called Reverse Ajax: Sending data from the server to a JavaScript-Enabled client (as opposed to a Regular Ajax, when the Client is the one that starts the communication). There 's a nice article on DeveloperWorks that can introduce you into the subject.
There are several ways to accomplish Reverse Ajax, and them imply some customization in both Client Side components (i.e JavaScript) and the Server Components (Java in your particular case). As WebServer says, WebSockets is one alternative -although is not supported by all browsers yet- but another viable solution is using Comet. If you're using Tomcat, this link might help you.
Related
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'm creating an app wherein the database are uploaded online without website, the concept of the app is like Waze app. I dont know where to start im asking for ideas and help. do i need to create a web server?how?i will mark this correct for those who can answer thanks.
This is not a simple task because it relies on many parts doing its proper job... In order to do what you want to do you need basically 5 things:
1.- Server: which will feed live information to the app.(There is a ton of servers that can be used to get this part done. If you are used to, or willing to learn php, I suggest you to start researching XAMPP (it uses Apache server running php stuff) [https://www.apachefriends.org/es/index.html]).
2.- Database: Most likely the server will need to work with information stored in some place. databases are perfect for just that. XAMPP also comes with MySQL which happens to be the most popular open source database out there.
3.- Format :You need to determine how the information will be passed from the server to the mobile device. The most common ways are: JSON which is plain text, XML that also is plain text but formatted diferently. this is important because you have to send the information from the server using this format and also your mobile devices will need to interpret the information in this format.
4.- Choose a way to send and recive the information : i would suggest Http/Ip protocol for this, as it is very common. Investigate Http requests and responses.
5.- Your device must be listening (or asking) for the content : the device will have to implement some sort of timer to ask the server for new information. This is determined by the logic and prupose of what you wish to do.
do i need to create a web server?
Yes! You need to create a web server, then, a webservice (database query etc...) which communicate between your application and your webserver. I think that all!
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
This is not about restricting opening multiple instances. I wrote a little app that creates reports and send scheduled emails. This app is on a common drive folder that everybody in our company has access to.
I want to set it up the way so that it would really execute only from my computer (like a server). However, all other people could open it and see all the processes that are going on at the instance that is open on my computer and could also make modifications etc
How can I do it?
A single copy of an app running on a server and handling requests from multiple locations... that's called "client-server" and you have essentially two choices:
A modern HTML-based web application (aka "thin client", but the "thin" part is debatable nowadays). The user interface is implemented in HTML/Javascript/CSS, runs on the client's browser, and interacts with a web server over the network (HTTP or AJAX or both) to execute the application logic. The main advantage of this is that the client needs only a modern web browser and can be run on any platform that supports the browser (Windows, Linux, iOS, MacOS, etc)
A "fat client" application. You write the user interface using Java/Swing/AWT/GWT/etc, and a server component also using Java. They communicate over the network using whatever you want to layer on top of TCP/IP. This can also run on many clients but they must have Java installed, so iOS is probably out. And clients may need to install Java, and some users may not want to. I.e. some clients might encounter a barrier to running your app.
A detailed explanation of how to write client-server apps is far beyond the scope of SO. You'll need to do a lot of reading and studying.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions concerning problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself. See SSCCE.org for guidance.
Closed 9 years ago.
Improve this question
I want for my java application which I have started to develop to 'communicate' with my webpage. However I have no experience with webpages and would like to know how things such as login using user/pass verification works. Any links to tutorials, where to start, and clarification would help me a lot! Thanks :)
Yes,You can use form at client side for send data to server side..
at at server side you can catch data by using getParameter method.
You can communicate via AJAX
You can store data in session.setAttribute('name', name) / session.getAttribute('name')
You can pass some data in GET-parameters (request.getParameter('userID'))
If you want to develop a simple web application with login functionality, you need to know following. You might want to start from
here
Java
Database (RDBMS or NOSQL)
HTTP Servers/ Request / Response
If you have already developed web app providing some service (such as REST services), you can develop a web client using jquery/backbone.js.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 9 years ago.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Improve this question
I want to develop a program, not language specific, that can redirect ANY connection to another one, like a proxy server, but for all connections. The language doesn't really matter, but is there a way to do this without modifying raw windows apis and such? I'm going to attempt this in java, but I can import C and C++ code with JNI. Also, what about mac/linux?
You should certainly consider/evaluate using TCP/UDP splice. It is a well-known mechanism for building proxies and is fairly efficient in terms of copying data form one connection to another.
URL: http://linux.die.net/man/2/splice
Java is the wrong language to attempt to do this in. Even if it is possible (e.g. on Windows), the real work would need to be done either using external utilities, or using native library calls.
Attempting to do this for multiple operating systems makes this even harder. The implementation mechanisms are bound to be different.
I don't know how you would do this in Windows, but on a modern Linux system you might do this using "iptables" to enable and configure the network packet processing in the OS kernel. This requires root privilege, a good understanding of the way that network protocols, and care ... since it is easy to "brick" your networking to the degree that you need console-level access to recover.
(And if you are using OS-level virtualization, it can get particularly complicated ...)
FWIW - It is possible to install and use a port of "iptables" on Mac OS/X ... thought it is apparently not supported by Apple.
On the other hand, if you are simply trying to have a Java application direct all of its own outgoing network connections via some kind of proxy, then you should be able to do this by configuring a custom SocketFactory implementation.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 9 years ago.
Improve this question
I'm exploring VPN Connectivity in Android.
I want to know how to setup a VPN connection in Android using an application.
I came across some sample code named ToyVpn. I ran the application but I didn't know what data I had to give in the form displayed by that application. Considering I have a VPN server with an IP address (say 10.162.1.2), what do I need to do in that application so this app work ?
If I try to use a public VPN server, what do I need to do?
I downloaded OpenVPN source code from GIT/ics-openvpn and I compiled it and ran on my ICS device, but I didn't know how to configure the data that needs to be entered.
Please can somebody provide the exact way to use this app ?
I want to know how to setup a VPN connection in Android using an application?
The Android SDK comes bundled with a sample; see ToyVpn in the android-16 samples directory. Also consult the documentation for VpnService and VpnService.Builder.
I came across a sample code namely ToyVpn.I ran the application but i dont know what datas i need to give in the form shown by that application, Consider iam having a VPN server with ip-address (say 10.162.1.2), What i need to do in that application to make that app work .
Your VPN will need to create a new socket, protect the socket from being routed back into the VPN using VpnService.protect(Socket), and connect the socket to 10.162.1.2. Having set up a tunnel connection to the VPN server, you should proceed to writing the input stream of the VpnService's interface into the tunnel's output stream, and in turn write the tunnel response back into the interface output stream.
If i try to use any public VPN server, What i need to do?
There is no standard mechanism in place for setting up a connection to a VPN server. ToyVpn simply communicates over a socket using raw TCP packets. You can either implement an existing protocol (see RFC 4026) like OpenVPN has done or write something yourself.