tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christoph Schaper <>
Subject Problem with REMOTE_HOST
Date Mon, 02 Oct 2000 10:25:52 GMT
I am quiet new to java servlets and java in general.
I succesfully install tomcat 3.1 to work with
apache with several VMs bound to Virtual Hosts.
Servlets and JSP work just fine and i also got a bit
into taglibs and alikes.
Since im new to java i ran into a problem and cannot figure out
what i am doing wrong here, i know this is a bit out of
topic but very related to servlets cause im trying to
work around a lack of an environment variable.
The Apache Server doesnt resolve Hostnames of Clients so i
dont get anything like REMOTE_HOST. But i do get
a REMOTE_ADDR. What i now wanted to do was a tag or servlet
or maybe just a tiny scriplet that resolves the hostname for me
if i dont get one ( or at least tries to ).
My attempt was this :

package tags;

import javax.servlet.jsp.*;
import javax.servlet.jsp.tagext.*;
import javax.servlet.*;

public class YourHostName extends TagSupport {
  public int doStartTag() {
   try {
     ServletRequest request = pageContext.getRequest();
     JspWriter out = pageContext.getOut();
     String ipadresse = request.getRemoteAddr();
     out.print(ipadresse.getHostName());   // This is the trouble
   } catch (IOException e) {
       System.out.println("Fehler : " + e );
Could anybody explain to me what im doing wrong here ?
And maybe explain also how to set this up as a java-bean and where to
place it ?
The taglib thingy works quiet well so far.
  Christoph Schaper

View raw message