tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christoph Schaper <christ...@schaper.org>
Subject Problem with REMOTE_HOST
Date Mon, 02 Oct 2000 10:25:52 GMT
Hello,
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 java.io.*;
import java.net.*;
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
line     
     out.print(ipadresse);
   } catch (IOException e) {
       System.out.println("Fehler : " + e );
  }
 return(SKIP_BODY);
 }
}
 
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.
Thanks
Christoph
---------------------------------------
  Christoph Schaper
  email :christoph@schaper.org
  homepage http://schaper.org/christoph
           http://schaper-edv.de
---------------------------------------

Mime
View raw message