views:

93

answers:

3

Hi,

My print application has to get the client name and then print the documents. How to find this in java script or jsp? I searched here. Some are discussing on PHP and so? Something discussed about running secure applet to get the client computer name? If so please give me example to do that? Thanks to all

A: 

You can't do it with Javascript. Try building a Java applet and:

java.net.InetAddress i = java.net.InetAddress.getLocalHost();
System.out.println(i.getHostName());
Júlio Santos
A: 

For MSIE on windows you can use this:

<script type="text/jscript">
<!--
var net = new ActiveXObject("WScript.Network");
alert(net.ComputerName);
//-->
</script>

...but: the page has to be "trusted"!(and of course jscript is not javascript)

Dr.Molle
A: 

How to find this in java script or jsp?

You cannot do this in a JSP, because the JSP executes on the server side. (In theory a JSP could try to determine the client IP address from the request object via the getRemoteAddr() method, but this will fail if the user's browser accesses the server via a web proxy.)

Stephen C