How to get Domain Name via JSP?

Discussion in 'Java' started by Ed, May 18, 2004.

  1. Ed

    Ed Guest

    What is the quick and easiest way to get the domain name in JSP?
    Ed, May 18, 2004
    #1
    1. Advertising

  2. Ed wrote:

    > What is the quick and easiest way to get the domain name in JSP?


    What or whose domain name are you talking about?

    --
    Kind regards,
    Christophe Vanfleteren
    Christophe Vanfleteren, May 18, 2004
    #2
    1. Advertising

  3. Ed

    Ed Guest

    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.

    "Christophe Vanfleteren" <> wrote in message
    news:U6pqc.115185$-ops.be...
    > Ed wrote:
    >
    > > What is the quick and easiest way to get the domain name in JSP?

    >
    > What or whose domain name are you talking about?
    >
    > --
    > Kind regards,
    > Christophe Vanfleteren
    Ed, May 18, 2004
    #3
  4. Ed

    Chris Smith Guest

    Ed wrote:
    > What is the quick and easiest way to get the domain name in JSP?
    >


    request.getServerName()

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

    Chris Smith - Lead Software Developer/Technical Trainer
    MindIQ Corporation
    Chris Smith, May 18, 2004
    #4
  5. Ed

    Ed Guest

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

    "Chris Smith" <> wrote in message
    news:4.net...
    > Ed wrote:
    > > What is the quick and easiest way to get the domain name in JSP?
    > >

    >
    > request.getServerName()
    >
    > --
    > www.designacourse.com
    > The Easiest Way to Train Anyone... Anywhere.
    >
    > Chris Smith - Lead Software Developer/Technical Trainer
    > MindIQ Corporation
    Ed, May 18, 2004
    #5
  6. Ed

    Chris Smith Guest

    Ed wrote:
    > 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
    Chris Smith, May 18, 2004
    #6
  7. Ed

    Chris Smith Guest

    Ed wrote:
    > 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
    Chris Smith, May 18, 2004
    #7
  8. Ed

    Ed Guest

    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.


    "Chris Smith" <> wrote in message
    news:4.net...
    > Ed wrote:
    > > 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
    Ed, May 18, 2004
    #8
  9. Ed

    Chris Smith Guest

    Ed wrote:
    > 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
    Chris Smith, May 18, 2004
    #9
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Dave
    Replies:
    4
    Views:
    2,880
  2. Joey
    Replies:
    0
    Views:
    343
  3. ding feng
    Replies:
    2
    Views:
    2,801
    ding feng
    Jun 25, 2003
  4. Replies:
    0
    Views:
    4,347
  5. Chem Leakhina
    Replies:
    2
    Views:
    137
    Robert Klemme
    Jun 23, 2009
Loading...

Share This Page