aspose file tools*
The moose likes Servlets and the fly likes Hwo to find the origin of a request Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Hwo to find the origin of a request" Watch "Hwo to find the origin of a request" New topic
Author

Hwo to find the origin of a request

Matt Brown
Ranch Hand

Joined: Jan 26, 2004
Posts: 70
I have a Servlet that need to handle the requests from different companies.
How do I find the origin of the requests, i.e., from which company the request
was sent? Can I get very fine level to know which computer send the
request?


"I just use my muscles as a conversation piece, like someone walking a cheetah down 42nd Street." - Arnold Schwarzenegger
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

You have a slew of methods in HttpServlet request and it's parent ServletRequest such as getRemoteAddr, getRemoteHost, getHeaders, etc...
http://java.sun.com/j2ee/sdk_1.3/techdocs/api/javax/servlet/http/HttpServletRequest.html

You could also map the company to the user's JSPSESSIONID when they log in.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Matt Brown
Ranch Hand

Joined: Jan 26, 2004
Posts: 70
Is the remote IP address I got from these APIs, for example, request.getRemoteAddr(), at desktop/laptop computer
level or at the server level of the remote company?
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

If a machine is behind a subnet, you're not going to be able to get it's internal IP.
Matt Brown
Ranch Hand

Joined: Jan 26, 2004
Posts: 70
If I use a wireless router which can be
connected by many computers, Could I get the IP of the router? What if
the router is installed in a home, in a hotel, or within a
company network? I guess anything behind the router is in the subnet domain. Thanks.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Hwo to find the origin of a request