How to get Domain Name via JSP?

E

Ed

I need the domain name when I login into my jsp application. I need the
domain name of my local network but I don't want to hard code it.
 
C

Chris Smith

Ed said:
That only gives me the name of the web server. I need the domain...

Then you'll need to clarify what you mean by "domain name". The name
returned by getServerName() is the name which was looked up via DNS
(which is the "domain name service") by the client.

If you want only the domain part of it, the following code will work:

int index = serverName.indexOf('.');
if (index == -1) domainName = null;
else domainName = serverName.substring(index + 1);

Is that what you want? Or something else?

--
www.designacourse.com
The Easiest Way to Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
 
C

Chris Smith

Ed said:
I need the domain name when I login into my jsp application. I need the
domain name of my local network but I don't want to hard code it.

Oh, you want the name of the client. In that case, try
request.getRemoteHost() instead.

--
www.designacourse.com
The Easiest Way to Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
 
E

Ed

What I'm looking for is the actually name of the domain where a user logs
onto their network. For example when you log onto your machine at work if
it is on a windows environment you have a User Name:, Password: and Log on
to: fields to input. I want to know what is the value that a user inputs
for the Log on to: field, which should be the domain of the network. I need
this value for a authentication process.
 
C

Chris Smith

Ed said:
What I'm looking for is the actually name of the domain where a user logs
onto their network. For example when you log onto your machine at work if
it is on a windows environment you have a User Name:, Password: and Log on
to: fields to input. I want to know what is the value that a user inputs
for the Log on to: field, which should be the domain of the network. I need
this value for a authentication process.

Oh, that's completely different then. You want to know the Windows NT
network domain. Unfortunately, I don't know how you can find this out.
You're more likely to have luck hiding your servlets behind IIS, which
is designed more for these kinds of Microsoft-specific networks than the
core servlet API.

--
www.designacourse.com
The Easiest Way to Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top