aspose file tools*
The moose likes Servlets and the fly likes how to  specify  domain in Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "how to  specify  domain in "url" , in getServletContext() . getContext("url")" Watch "how to  specify  domain in "url" , in getServletContext() . getContext("url")" New topic
Author

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

vijay dadhwal
Ranch Hand

Joined: Dec 02, 2008
Posts: 47

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)


MCA , SJCP
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

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.


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

Joined: Dec 02, 2008
Posts: 47

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

Joined: Jun 06, 2007
Posts: 2713
    
    5

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

By using redirect.


SCJP, SCWCD.
|Asking Good Questions|
vijay dadhwal
Ranch Hand

Joined: Dec 02, 2008
Posts: 47

Hi,

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

regards
vj
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

If it's on a different server, you can't use requestDispatchers to forward or include.
vijay dadhwal
Ranch Hand

Joined: Dec 02, 2008
Posts: 47

Thanks
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to specify domain in "url" , in getServletContext() . getContext("url")
 
Similar Threads
Calling Servlet method from Bean
getServletContext() throws NullPointerException
difference between getContext(String uri) and getServletContext()
difference between ways of getting RequestDispatcher
passing session values between two web application