Sir/Madam,
I have design an application using java-applet in that i want to save pdf file on server location i.e http://www.mywebsite/myfolder/ . On local side it will run successfuly but actualy on server side it will not work.
As far as I understand, you would like the applet to store the file on the server. That is obviously not possible because the applet runs on the client. The option I can think of, is to implement an HTTP Post from the applet to the server and handle it on the server.
Short answer: applets run on client side so they save nothing on server.
Longer answer: that applet will have to communicate somehow with a server side-application. I.e. like this SO Q&A.
A question on tech stack: Is it really necessary to use applet? It's obsolete technology. Can't you use a jnlp rich client application? Or a simple webapp?
Related
I want to connect my android application to an applet which is running on my pc on Google chrome on Wi-fi.. where my phone works as a wi-fi hotspot and pc as the connected device. I want the connection to work uniquely as I want commands to be passed from my application to the specific applet, on the execution of which my applet does specific tasks. Please tell me the APIs which I can look in both Java and Android or the technology I have to use to make it work..
You need to use any program, such as wamp server, to make your computer to be a localserver. It will install PHP 5, MySQL and Apache. In other hand, you will also need a little bit of knowledge in Php language to create you own web services.
Another thing you need to be aware is that to handle you connection between server and device (and by this I mean which IP you are going to use) you will have a little headache; but first things first..break your problem in little parts thus will be easier to solve them.
I recommend this tutorial.
I think the simple way to connect these two softwares is using UDP.
It is fast, it is easy to program but it is generally unreliable according to TCP. But it is already local network. I dont think that is a case you need to take care in your local wifi network.
So take a look at this tutorial http://tutorials.jenkov.com/java-networking/udp-datagram-sockets.html
There are other ways like https://www.alljoyn.org/. It has more functinality but more complicated.
You must install Server on your PC(Apache httpd or apache tomcat or other based on your interest). A server listens to request from clients. When your mobile is connected to your pc(doesn't matter wire or wireless), you can make a request to an url(say, localhost:8080/welcome) from your app.
Create an applet and connect it with your web application(in the server) using java.net.URL and java.net.URLConnection.
On performing some operation on the client, call the url of the server application and forward the response to the applet.
I would like to know if when I launch my Java Web Start application, I'm using my browser or the connection is directly from the Java sandbox against the server through Http/Https protocol.
I want ot know, wether once the JAR has been downloaded and stored locally, next time when the applciation is launched, it will use my browser?
No, Java WebStart doesn't use the browser. It uses the JRE to connect to a remote server using HTTP or HTTPS.
The browser is only involved in the download of the .jnlp file. And even here, you could send the JNLP file by e-mail or any other mean. It would work too.
I want the browser to send a message to my local Java application (which is programmed by myself) when I click a button on a web page which is also written by myself using php. Is there any way I can do that?
This is the wrong way. You don't send information from your server to your local application. Your local application should grab the information from your web server.
The local Java application can implement a webserver. There is a number of libraries out there, or you can use ServerSocket / SSLServerSocket to implement it low level. The server socket should be bound to localhost in order to prevent direct external access.
You can use JSONP to communicate with this local webserver.
Pay special attention to authentication, because any website you visit, can instruct the browser to send requests to the local webserver.
I have embedded a JSCH SSH Java applet in a web page and need to know if it's possible to run a script (of any language like PHP) to automate logging in and running commands. I have heard of expect4j and java robot but cannot see any way to implement it. Keep in mind, I'm not great with Java so I don't know everything about it. Any help is appreciated.
JSch is an SSH client library, and by itself only allows programmatically steered connections to another server. The user interaction has to be build around it by users of the library.
The JCTerm applet provided on the website also contains a terminal emulator in form of a Java GUI. If you only want to automatically execute some command (and maybe show its output in the web page), you could do everything on the server side, and don't need the applet with its terminal emulator. (You would need either some PHP-Java bridge on the server side or some Java-enabled webserver with a Servlet or similar, though.)
(If the web server would be the same machine as the server you'll run the command on you wouldn't even need the SSH connection, but could execute the stuff directly.)
If the server can't do anything (i.e. a "static server"), an applet is the way to go, yes. You can either modify JCTerm or create a new applet from scratch (using JCTerm's connection code as an example on how to connect to to the server).
If you don't have to fear any malicious users in your LAN (i.e. between web server and user, the SSH server doesn't matter), you can embedd the password (or preferably a private key for public-key authentication) into the applet's jar file, and pass it to the library for connection. (You should also include the server's public key for easier checking.)
Provide the command(s) to a ChannelExec (instead of a ChannelShell), this makes it easier to provide input (if necessary) and capture the output. Pipe the output in a text area, or simply use a green/red label saying if the command was successfully executed.
(I might have a look at this in the next days and try to do it. No promise, though.)
I have created an applet which creates a file on running it. But when I run my applet via server, it fails.
Is there any possible way to create a file on server with applet?
EDIT:I am creating a sound record applet which works fine when I run the applet in browser locally.It actually creates a file of recorded sound,but when I run the same applet on server,it does not create file.Is it because the server does not allow you to do so?
Is there any possible solution so that the file can be created?
File objects always point to a location (that may not exist) on the client machine.
To store something on a server, it would require some server side functionality to accept the bytes and create a (server-side) File. That might be done with PHP, servlets/JSP, ASP etc. Once the server-side is organized to accept the bytes, the applet can connect to it and push the sound recording through.
Java Applets are run on the client machine. Once you invoke the page containing an applet, the applet gets downloaded to the client's machine and runs. Hence it will not get access to the server.