ServletRequest - can I get the host name exactly as requested?

Discussion in 'Java' started by pwfarwell@yahoo.com, Jan 24, 2006.

  1. Guest

    I am seeing a problem with the ServletRequest getServerName() method.
    On JBoss and Weblogic, this method returns the host name exactly as it
    was specified in the request.

    If the original request was:

    http://fooHost/dir1/dir2/some.html

    getServerName() returns "fooHost" as the server name for JBoss and
    Weblogic.

    But on Oracle Application Server, getServerName() returns the fully
    qualified host name, e.g. "fooHost.acme.com". This causes problems with
    an AJAX call that attempts to match "fooHost" with "fooHost.acme.com",
    and fails because the two strings don't match (even though they point
    to the same server).

    Does any one know a more reliable way to get the host name (in a form
    that matches the original request)? Is there a better option than
    getServerName()?
     
    , Jan 24, 2006
    #1
    1. Advertising

  2. wrote:
    > I am seeing a problem with the ServletRequest getServerName() method.
    > On JBoss and Weblogic, this method returns the host name exactly as it
    > was specified in the request.
    >
    > If the original request was:
    >
    > http://fooHost/dir1/dir2/some.html
    >
    > getServerName() returns "fooHost" as the server name for JBoss and
    > Weblogic.
    >
    > But on Oracle Application Server, getServerName() returns the fully
    > qualified host name, e.g. "fooHost.acme.com". This causes problems with
    > an AJAX call that attempts to match "fooHost" with "fooHost.acme.com",
    > and fails because the two strings don't match (even though they point
    > to the same server).
    >
    > Does any one know a more reliable way to get the host name (in a form
    > that matches the original request)? Is there a better option than
    > getServerName()?
    >


    The problem with Oracle AS is that you are likely accessing the
    containers via Web Cache and/or Apache. When relaying the request,
    Oracle probably uses the fully qualified domain name to find the next
    node in the chain. So by the time it gets to the J2EE containers, there
    may be no way to distinguish between a request for "foohost" and
    "foohost.acme.com".

    HTH,
    Ray

    --
    This signature intentionally left blank.
     
    Raymond DeCampo, Jan 24, 2006
    #2
    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. Orpheus66
    Replies:
    0
    Views:
    4,478
    Orpheus66
    Jul 30, 2003
  2. Joerg Gippert

    ServletRequest.setAttribute question

    Joerg Gippert, Jul 30, 2003, in forum: Java
    Replies:
    2
    Views:
    3,141
    Joerg Gippert
    Jul 31, 2003
  3. Santosh
    Replies:
    2
    Views:
    452
    Chris Smith
    Sep 8, 2004
  4. sasuke
    Replies:
    3
    Views:
    1,324
  5. Replies:
    13
    Views:
    1,325
Loading...

Share This Page