Results 1 to 11 of 11
Thread: Client-jar Server-war
- 03-24-2012, 08:48 PM #1
Member
- Join Date
- Feb 2012
- Posts
- 16
- Rep Power
- 0
Client-jar Server-war
Hello, I would like to ask how get resolve this problem, if it's possible. I have client application(common JAR file) and server application(common WAR file)(server part haven't gui, it's only backend part). I need send files to server after verification of client, but I don't know, how send more values in socket between client and server. I need some this communication, if this possible.
1) Client send username, password to server. (but what?)
2) Server send client true or false. (but what?)
3) Client works true or false ... if it's true, so client will send random count of files (I use BufferedInput/OutputStream)
4) Client send some symptom, that it ended with sending.(but what?)
I find some solution, what I solve this communication between client and server. Can you help me with this problem? Thanks.
- 03-24-2012, 09:00 PM #2
Re: Client-jar Server-war
What does the (but what?) mean?1) Client send username, password to server. (but what?)
Are you writing new code, changing existing code or using existing code?
I'm not sure what your problem is.
Are you asking about defining a protocol between a client and server that can be used for the client to send an unknown number of files to the server?If you don't understand my response, don't ignore it, ask a question.
- 03-25-2012, 09:17 AM #3
Member
- Join Date
- Feb 2012
- Posts
- 16
- Rep Power
- 0
Re: Client-jar Server-war
I can send file to server but it's only one file and without credentials. I want to create some connection, which send to client true or false and client then can send unknown number of files.
First problem: I don't know what send username and password to the server. (Server now I have connected with database and they communicate)
- 04-10-2012, 03:29 PM #4
Member
- Join Date
- Feb 2012
- Posts
- 16
- Rep Power
- 0
Re: Client-jar Server-war
So, now I can send some data to Server, but I have another idea of how this I wanted to do. I would like to have a WAR file, which will process requests from clients. But I don't know, how to create. Can you me help how to create server as WAR and will listen to some port. As java application source it works me. Server and Client are running in different threads and here is me code:
Server:
Client:Java Code:public class Server { public static int port = 81; public Server() { while (true) { receiveString(); } } private void receiveString() { ServerSocket sSocket = null; Socket socket = null; BufferedReader reader = null; try { sSocket = new ServerSocket(port); socket = sSocket.accept(); ObjectInputStream input = new ObjectInputStream(socket.getInputStream()); System.out.println("SERVER: " + input.readObject()); ObjectOutputStream out = new ObjectOutputStream(socket.getOutputStream()); out.writeObject("FALSE"); if (!sSocket.isClosed()) { sSocket.close(); } } catch (IOException e) { e.printStackTrace(); } catch (ClassNotFoundException e) { e.printStackTrace(); } } }
Java Code:public class Client { public Client() { sendString(); } private void sendString() { int port = 81; String username = "user / "; String pass = "pass"; Socket socket = null; try { socket = new Socket("127.0.0.1", port); ObjectOutputStream out = new ObjectOutputStream(socket.getOutputStream()); out.writeObject(username + pass); } catch (UnknownHostException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } while (true) { try { ObjectInputStream input = new ObjectInputStream(socket.getInputStream()); System.out.println("CLIENT: server data -->" + input.readObject()); String s = (String)input.readObject(); System.out.println(s); if(s.equals("FALSE")) { socket.close(); } } catch (UnknownHostException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } catch (ClassNotFoundException e) { e.printStackTrace(); } } } }
- 04-10-2012, 04:02 PM #5
Re: Client-jar Server-war
Sorry, I do not know about WAR files.
If you don't understand my response, don't ignore it, ask a question.
- 04-10-2012, 04:35 PM #6
Member
- Join Date
- Feb 2012
- Posts
- 16
- Rep Power
- 0
- 04-10-2012, 04:38 PM #7
Re: Client-jar Server-war
I'm not familiar with war either. What program used war files?
If you don't understand my response, don't ignore it, ask a question.
- 04-10-2012, 04:45 PM #8
Member
- Join Date
- Feb 2012
- Posts
- 16
- Rep Power
- 0
Re: Client-jar Server-war
I would like to have a server that has no user interface. Only handles requests that come from the client (my JAR client). And I could deploy to the Tomcat server, so I need a WAR package.
- 04-10-2012, 05:00 PM #9
Re: Client-jar Server-war
Are you saying the Tomcat server knows how to read and use the contents of war file? I don't use Tomcat.
If you don't understand my response, don't ignore it, ask a question.
- 04-10-2012, 05:05 PM #10
Member
- Join Date
- Feb 2012
- Posts
- 16
- Rep Power
- 0
Re: Client-jar Server-war
And is it possible to solve it somehow, if I want to use Tomcat?
- 04-10-2012, 05:15 PM #11
Similar Threads
-
TCP Two-Client-Server/Client Program not doing what I expected
By xenoepist in forum Advanced JavaReplies: 6Last Post: 01-09-2012, 09:30 PM -
server-client; client sends a username to the server.
By lkcz in forum New To JavaReplies: 2Last Post: 09-24-2010, 11:31 AM -
Datagram Client and Server, client timer question
By saru88 in forum NetworkingReplies: 1Last Post: 10-05-2008, 03:12 PM -
Identify Client in Socket Client Server Application
By masadjie in forum NetworkingReplies: 1Last Post: 12-20-2007, 09:18 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks