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

P

pwfarwell

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()?
 
R

Raymond DeCampo

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
 

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,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top