You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Christoph Schaper <ch...@schaper.org> on 2000/10/02 12:25:52 UTC
Problem with REMOTE_HOST
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
---------------------------------------