• Post Reply Bookmark Topic Watch Topic
  • New Topic

Client-Server Communication using servlets  RSS feed

 
nikitha kakani
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi everyone,i have to get avaliable ports on client side
portList =CommPortIdentifier.getPortIdentifiers();
int c = 0;

while ( portList.hasMoreElements()) {
System.out.println(" c == "+ c);
c++;
portIdentifier = (CommPortIdentifier)portList.nextElement();
System.out.println(portIdentifier.toString());
System.out.println(portIdentifier.getName());
}


portIdentifier = CommPortIdentifier.getPortIdentifier("COM1");
System.out.println(portIdentifier+"portIdentifier");
portID = (SerialPort)portIdentifier.open("Serial",10);




when client sends request the server knows ipaddress of client can it open client ports (OR) is there any other solution .Please help me
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not sure what you're trying to do, but if the client sends a request to the server, then the server only needs to accept that request in order to establish a connection. Nothing further is required, in particular not that the server contacts the client in some other way.

Also be aware that servlets will not be accessible by any means except being called by the servlet container in response to requests over ports configured for HTTP(S).

You could start a new thread that uses a ServerSocket for listening to other ports, though.
[ January 29, 2008: Message edited by: Ulf Dittmer ]
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mistakenly posted by nikitha kakani in a new thread:
actually my problem is i need to send an sms using GSM modem .when a client sends request the server need to open the client ports ,is this possible through servlets(MVC1) or do i need to use RMI is that the only way

[ January 29, 2008: Message edited by: Ulf Dittmer ]
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I see. You don't want to communicate with the client that sent the request to the servlet, but want to access a connected device as a client.

A servlet is just regular Java code; it can use all communication facilities Java has. Which brings up the question: How is the GSM modem connected? Do you have a Java API for accessing it?

By the way, it's highly unlikely that RMI would be part of any solution, in my opinion.
 
nikitha kakani
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks for the reply.thanks a lot .whatever you said is correct but my servlet takes com ports of server it need to take client system's so i am using servlets(my project is webapplication) ..if any thing wrong please correct me
If i have any douts where should i post and how to start new thread.
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
my servlet takes com ports of server it need to take client system's so i am using servlets(my project is webapplication)

I don't understand what that means. What exactly is the "client" you're talking about? Who or what is making the request to the servlet?

In any case, as I pointed out above, the servlet needs to access the GSM modem somehow - so how is it connected?

(If you have follow-up questions, posting them in this thread is the right thing to do.)
 
nikitha kakani
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi , "client" exactly the browser .The browser is sending request to the servlet.but when i take port its giving server ports but actually i need client ports to be opened.As a servlet can take client ipaddress is there any possibility that it can also open client ports .sorry i was asking so many questions i have no way no one is helping me as they too are travelling in same ship .
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I see. The modem is connected to the client machine that makes the request to the server through a browser. There's no way to do this. The server has no access to (or influence on) the client's communication facilities.

A properly privileged applet should be able to do this -since it runs on the client- but not a web app running on the server.
 
nikitha kakani
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
so applet can open client com ports .Ok i will try if i have any douts can i ask you in this same post ?bye once again i am very thank ful to you
 
Nicholas Jordan
Ranch Hand
Posts: 1282
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am sure what the poster is trying to do can be handled with name=value pairs.


These paramater names and values can be worked to implement some sort of "ports" - the actual handling of ports ( as traditionally used in the rfc's ) should be left to Java and the OO programming paradigm.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by nikitha kakani:
so applet can open client com ports .Ok i will try if i have any douts can i ask you in this same post ?bye once again i am very thank ful to you


As Ulf said: A "properly privileged" applet can do this.
You will either need to have a security policy installed on the client machine that allows your applet to do this or digitally sign your applet.
With the second option the user will still be prompted to authorize this.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!