Results 1 to 11 of 11
  1. #1
    basfot is offline Member
    Join Date
    Feb 2012
    Posts
    16
    Rep Power
    0

    Default 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.

  2. #2
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,273
    Rep Power
    25

    Default Re: Client-jar Server-war

    1) Client send username, password to server. (but what?)
    What does the (but what?) mean?

    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.

  3. #3
    basfot is offline Member
    Join Date
    Feb 2012
    Posts
    16
    Rep Power
    0

    Default 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)

  4. #4
    basfot is offline Member
    Join Date
    Feb 2012
    Posts
    16
    Rep Power
    0

    Default 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:

    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();
    		}
    	}
    }
    Client:
    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();
    			}
    		}
    	}
    }

  5. #5
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,273
    Rep Power
    25

    Default 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.

  6. #6
    basfot is offline Member
    Join Date
    Feb 2012
    Posts
    16
    Rep Power
    0

    Default Re: Client-jar Server-war

    Quote Originally Posted by Norm View Post
    Sorry, I do not know about WAR files.
    Excuse me, of course I think package war.

  7. #7
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,273
    Rep Power
    25

    Default 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.

  8. #8
    basfot is offline Member
    Join Date
    Feb 2012
    Posts
    16
    Rep Power
    0

    Default 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.

  9. #9
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,273
    Rep Power
    25

    Default 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.

  10. #10
    basfot is offline Member
    Join Date
    Feb 2012
    Posts
    16
    Rep Power
    0

    Default Re: Client-jar Server-war

    And is it possible to solve it somehow, if I want to use Tomcat?

  11. #11
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,273
    Rep Power
    25

    Default Re: Client-jar Server-war

    Does Tomcat have documentation on how to use it? Try reading that.
    If you don't understand my response, don't ignore it, ask a question.

Similar Threads

  1. Replies: 6
    Last Post: 01-09-2012, 09:30 PM
  2. Replies: 2
    Last Post: 09-24-2010, 11:31 AM
  3. Replies: 1
    Last Post: 10-05-2008, 03:12 PM
  4. Identify Client in Socket Client Server Application
    By masadjie in forum Networking
    Replies: 1
    Last Post: 12-20-2007, 09:18 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •