• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Get the website name in the sevlet

 
koteswar sirikonda
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI, I have a requrement to know the website name from where the request has come from.
I created one link that can be used by any no of websites. If any one click on the link the request is come to my application. I want to know in which website the link has been clicked.
Can any one help me please.
 
Wouter Oet
Saloon Keeper
Posts: 2700
IntelliJ IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can view the referrer information but that information is optional. Although most browser do sent it I've disabled it and it won't be send if the link is accessed directly so it won't work always.
 
Ravi Kiran Va
Ranch Hand
Posts: 2234
Eclipse IDE Firefox Browser Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If the two web sites are under your control then set any request attributes in them , check them in your code .

If the two web sites were not in your control , access the IP address of this web sites and do your logic
 
Wouter Oet
Saloon Keeper
Posts: 2700
IntelliJ IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ravi Kiran Pattu wrote:access the IP address of this web sites
And how would you do that?
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Look at the methods provided by the HttpServletRequest object.

http://tomcat.apache.org/tomcat-5.5-doc/servletapi/javax/servlet/http/HttpServletRequest.html

With them you can find the domain, contextPath, IP, etc ...
 
Wouter Oet
Saloon Keeper
Posts: 2700
IntelliJ IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But that is the ip address of the client. Not of the website on which the client clicked on the link.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Wouter Oet wrote:But that is the ip address of the client. Not of the website on which the client clicked on the link.



Yep, just re-read the OP's question (after a cup of coffee) and realized that he was looking for the info from the referrring site.

Thanks for pointing that out.
 
Bhoomika Bathla
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
use this : -

String refererPage = request.getHeader("referer");

Try to print value of refererPage.It will print the name of website from which it is coming.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bhoomika Bathla wrote:use this : -

String refererPage = request.getHeader("referer");

Try to print value of refererPage.It will print the name of website from which it is coming.


The referer header was already discussed earlier in this thread.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic