B4J Question WEB app - computer name

besoft

Active Member
Licensed User
Longtime User
Hi,

Is it possible to get the web application computer name on which the application is running?
 
Thx

That's what I was looking for.

The idea was the name of the computer, which is connected to an application on the server.
 
Upvote 0
My mistake. This code returns the name of the computer on the server side. I need on the client side.
I found this http://stackoverflow.com/questions/20492186/get-client-machine-name-in-lan:
Code: Copy
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {

    Logger.getLogger(this.getClass()).warning("Inside Confirm Servlet");
    response.setContentType("text/html");

    String hostname = request.getRemoteHost(); // hostname
    System.out.println("hostname"+hostname);

    String computerName = null;
    String remoteAddress = request.getRemoteAddr();
    System.out.println("remoteAddress: " + remoteAddress);
    try {
        InetAddress inetAddress = InetAddress.getByName(remoteAddress);
        System.out.println("inetAddress: " + inetAddress);
        computerName = inetAddress.getHostName();

        System.out.println("computerName: " + computerName);


        if (computerName.equalsIgnoreCase("localhost")) {
            computerName = java.net.InetAddress.getLocalHost().getCanonicalHostName();
        }
    } catch (UnknownHostException e) {

        }

    System.out.println("computerName: " + computerName);

Can anyone review this. Is it possible to run this inside the B4J?

I tried, but it shows some errors. Because my knowledge is not extensive enough, I do not know to fix errors.
 
Last edited:
Upvote 0
Back
Top