How client server and deployed Java code connects each other? - java

Generally we learnt through http connection client server connection happens,
My question is we deploy .class files in server say tomcat, do
tomcat understands .class files?
As I learnt .class files are byte code understood by jvm means as per my understanding everything(protocal-webserver-javacode ) first converts to binary code and then communicates with each other,correct me if I'm wrong if so then please explain me in details and links to read more on it ?

Related

How to save file on server side using applet?

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?

Testing a ftp client program in Java

I have a java app that reads files kept on a remote server using ftp protocol, I used the org.apache.commons.net.ftp.FTPClientto write my ftp client side code, but I dont know how to test it.
I know this answer is a bit late, but if you want to test FTP client code, then take a look at MockFtpServer (http://mockftpserver.org).
You can test by putting logs after connect, login, listing files etc, and in catch block you print the stack trace until all your connections issues are resolved.

javasocketbridge - client not reading / java.net.SocketPermission

I am trying to achieve a TCP connection between a JavaScript client and a java server. (implementation must be this way I cannot swap to node for the server for example ).
Web sockets implmentation in java looked very complicated. I had a look at Jetty and JWebSocket and was quickly scared off. I have no idea what is going on in the source for them. – So I didn’t have much luck implementing a server using them.
So then I looked for websocket alternatives.
I noticed SocketBridge, It seems very straight forwards and offers exactly what I need for my project so I downloaded that.
I created a simple java server that just prints what I receives and sends a string as bytes back. I used the prebuilt JavaSocketBridge and modified the index.html to point to my server. My server recived the message but nothing showed up on the client.
function run(){
socket_connect('localhost', 31113);
socket_send("Hello from JavaSocketBridge applet");
}
I then decided to build the JavaSocketBridge to see if I could debug the read methods. However my build of JavaSocketBridge refuses to connect with the error.
Java Socket Bridge ERROR: Could not connect to localhost on port 31113
Access denied (“java.net.SocketPermission” “127.0.0.1:31113” “connect,resolve” )
(This was in chrome but it happens in firefox too)
So my questions:
Why does my build get a socket permission error?
Why does the client not receive anything even though the example does from google.com:80?
Notes.
My server appears to be working fine. (I have used a simple java client to test it.
I have used java 1.6 and 1.7 to build the JavaSocketBridge)
I have included C:\Program Files\Java\jre7\lib\plugin.jar
My System is Win7 64 and java SDK / JRE is up to date
Edit. Ive gone back to jetty and got a client/server working, however I will monitor this question.

Java Servlet: Retrieve data from remote devices and "push" data to client side by using FTP connection

I believe build a small home-made program to make ourselves more comfortable is quite common nowadays. Just few days before, I really tired to get the same named log files from different remote devices through FTP connection again and again so that I started to build one Java web application.
The purpose of the Java web application is simple as once the user filled in the absolute path of source file in remote device and selected corresponding remote devices he or she want to connect to, the web application will finally store those same named log files in user's local computer with well organized folder structure. You can simply understand that this Java servlet is a proxy sits between client and remote devices.
Currently, I have already done and tested the downloading function from remote devices to the server in Java servlet by using Apache common net FTPClient library. It worked fine and provided me the copies of same named log files in a well organized folder structure.
However, when I moved on, I realized that the "pushing" function maybe the killer. Following are few queries I want to discuss with you all:
Even I could get IP address or host name from client's requests, is it possible or suitable for me to auto establish a FTP connection from servlet to client?
If an auto FTP connection is achievable, what are the security concerns I should pay attention?
If an auto FTP connection is not achievable, is it possible or suitable for me to return those files in the response to the client?
I appreciate your comments or suggestions. Hope you all also enjoy the open discussion here.

Java server software not recieving connections when compiled to executable Jar

I have written code for a tcp (SSL) server which receives client connections and distributes data to the clients. the server GUI is based on JavaFX. When i run the server software from within Net Beans or Eclipse it works fine, receives client connections and sends and receives data. But when i compile the code into an executable Jar the server does not receive connections and client code throws: Connection refused exception.
I have tried pinging the server and it seems the server does not listen to the specific port when it is run from the executable Jar but DOES when run from within the IDE.
to be honest , I have no idea what could be causing this behavior. would appreciate any insights , suggestions or leads into how to fix this issue. I dont think the specific code is relevant but if somone thinks it is i will post the server code.
Well, turns out the problem was that the relevant keystores were not being loaded right. They were being loaded as FileInputStreams which will not work when embedded inside a Jar file.
I reverted them to being loaded as InputStreams , which work just as well with the SSL context and everything seems to be working right now.
Thanks a bunch for all the suggestions they defiantly helped me eliminate things along the way.

Categories

Resources