Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to specify domain in "url" , in getServletContext() . getContext("url")

 
vijay dadhwal
Ranch Hand
Posts: 47
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Need to access Context root of an web application running on different domain.

getServletContext().getContext("http:\\www.<domainname>:<port>\<context>")
returns null, also i learnt that we cannot specify domain as a part of url in getContext(url) method.

How do we achieve this ?

Regards
vj
SCJP (1.4.6)
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A context doesn't know what domain(s) under which it is running.
A request will know which domain was used to reach it; usually.

A container could be listening to several domains (or none).

For example, if your application is set up to run under www.abc.com, you could also hit that app from the local machine with localhost or no domain at all by typing in the IP 127.0.0.1.
 
vijay dadhwal
Ranch Hand
Posts: 47
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

If there are 2 web applications running on different domain servers
A.com & B.com

then how do a servlet/jsp from A.com could access servlet/jsp/html of B.com.

regards
vj
 
Amit Ghorpade
Bartender
Posts: 2854
10
Fedora Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
then how do a servlet/jsp from A.com could access servlet/jsp/html of B.com.

By using redirect.
 
vijay dadhwal
Ranch Hand
Posts: 47
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I want to use include(request,response) rather than response.sendRedirect().

regards
vj
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If it's on a different server, you can't use requestDispatchers to forward or include.
 
vijay dadhwal
Ranch Hand
Posts: 47
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic