An idea that I do not know if it works: I think you can access the referrer
of your first page by using JavaScript, and then include it as a parameter
in your <image src="/servlet/YourServlet?referring=page">-tag to get the
image. Maybe you will have to construct the call by using the
JavaScript-method document.write().

I do not think that there is a way for the servlet to access anything
earlier than the latest referring page (?) so I think it has to be done in
the webpage that contains the image. If so, then it turns out that the
question is kind of off-topic so mail me directly if you want to discuss it
more. I would be glad to find out if it works...

Hope this helps,
/Micael

> -----Ursprungligt meddelande-----
> Fr�n: Werner Moshammer [SMTP:[EMAIL PROTECTED]]
> Skickat:      den 16 september 1999 15:03
> Till: [EMAIL PROTECTED]
> �mne: Servlet / User Info Statistic
>
> I want to write a Servlet, which is called within a WWW-Page, and which
> gets some info about the surfer, especially the referrer page he is from.
>
> Just a servlet would be similar to the SnoopServet from Sun, but the
> result (the info) should not be reported to the user (=surfer), it should
> be
> written in a file, and the surfer should see the regular WWW Page (every
> page, in which this servlet is embedded, like in the sample HTML file
> below).
> (The servlet is for getting info for statistical purpose)
>
> So I am calling the servlet within a <img scr=...> HTML command, but ...
> and
> this is my problem ... the referrer page, which is written to the file is
> now the WWW page, where the servlet is embedded (and not the real referrer
> page)
>
> Does anybody know what I must do to get the right results?
>
> (Additional information: I am using Apache Webserver, JServ 1.0, JSDK 2.0,
> JDK 1.2.1)
>
>
> Here is the Servlet Source:
>
>
> import javax.servlet.*;
> import javax.servlet.http.*;
> import java.io.IOException;
> import java.io.*;
> import java.net.*;
> import java.net.MalformedURLException;
> import java.util.*;
>
> public class BasicSnooperServlet extends HttpServlet{
>
>   public void doGet(HttpServletRequest request, HttpServletResponse
> response)
>       throws ServletException, IOException {
>
>     ServletOutputStream out = response.getOutputStream();
>     response.setHeader("pragma", "no-cache");
>     response.setContentType("image/gif");
>
>     URL FilePath = new URL("http://localhost/stat.gif");
>     URLConnection fp = FilePath.openConnection();
>     InputStream ic =  fp.getInputStream();
>
>     int data    =   ic.read();
>     while (data !=-1) {
>        out.write(data);
>        data    =   ic.read();
>     }
>
>     try {
>       RandomAccessFile raf =  new RandomAccessFile("/greetings2.log",
> "rw");
>       raf.seek(raf.length());
>
>       Enumeration e = request.getHeaderNames();
>       if (e.hasMoreElements()) {
>  while (e.hasMoreElements()) {
>    String name = (String)e.nextElement();
>           raf.writeBytes(name+request.getHeader(name));
>  }
>       }
>
>     }
>     catch (IOException e2) {
>       System.out.println("Error opening file: " + e2);
>     }
>
>     out.close();
>   }
> }
>
>
>
>
> And here the HTML Source:
>
> <html>
> <body>
> This is the WWW-page, where the servlet is called<p>
> <img src="/servlets/BasicSnooperServlet">
>
> </body>
> </html>
>
>
> Thanks in advance for your help.
>
>  Werner Moshammer
>  [EMAIL PROTECTED]
>
> __________________________________________________________________________
> _
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the
> body
> of the message "signoff SERVLET-INTEREST".
>
> Archives: http://archives.java.sun.com/archives/servlet-interest.html
> Resources: http://java.sun.com/products/servlet/external-resources.html
> LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to