aspose file tools*
The moose likes Servlets and the fly likes Getting IP address of User Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Getting IP address of User" Watch "Getting IP address of User" New topic
Author

Getting IP address of User

rudresh kumar
Ranch Hand

Joined: Jan 04, 2006
Posts: 83
HI,

I have an J2EE application running on websphere server, Is there a way to get to know from which IP address does user 'X' has logged in ?.

Suppose a helpdesk team wants to know from which IP address does user 'X' has logged in.
Thanks
Srinivas Godavarthy
Greenhorn

Joined: Oct 13, 2007
Posts: 1
Hi, we can get the ip address of the requested system in your application. If you are using any servlet in your appliction then from HttpServletRequest you can get the ip address...see the following code..

public class TestServlet extends HttpServlet {
public void doGet (HttpServletRequest req,
HttpServletResponse res)
throws ServletException, IOException
{
PrintWriter out = res.getWriter();
String host = req.getRemoteAddr();
out.println("Hellow Your System IP is " + host);
out.close();
}
}
Rahul Bhattacharjee
Ranch Hand

Joined: Nov 29, 2005
Posts: 2308
Originally posted by Srinivas Godavarthy:
Hi, we can get the ip address of the requested system in your application. If you are using any servlet in your appliction then from HttpServletRequest you can get the ip address...see the following code..

public class TestServlet extends HttpServlet {
public void doGet (HttpServletRequest req,
HttpServletResponse res)
throws ServletException, IOException
{
PrintWriter out = res.getWriter();
String host = req.getRemoteAddr();
out.println("Hellow Your System IP is " + host);
out.close();
}
}


the above code would give the IP of the last proxy that the request is passing through.It would only give the required result if there are no proxy between the server and the client.


Rahul Bhattacharjee
LinkedIn - Blog
RockyDude
Greenhorn

Joined: Oct 14, 2007
Posts: 1

Suppose a helpdesk team wants to know from which IP address does user 'X' has logged in.


Try this out:
http://www.getfreesofts.com/script/548/23426/Display_IP_address_script_using_SSI_and_JavaScript.html
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61413
    
  67

"RockyDude",

There aren't many rules that you need to worry about here on the Ranch, but one that we take very seriously regards the use of proper names. Please take a look at the JavaRanch Naming Policy and adjust your display name to match it.

In particular, your display name must be a first and a last name separated by a space character, and must not be obviously fictitious.

Thanks!
bear
JavaRanch Sheriff


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Getting IP address of User