Re: Application front door URL

Lachlan Deck <[email protected]>
Newsgroups gmane.comp.web.webobjects.devel
Message-ID <[email protected]>
Hi there,

On 21/02/2006, at 8:03 PM, Markus Ruggiero wrote:

> Probably simple, but I cannot find an answer: How can an  
> application find out its own front door url? (/cgi-bin/WebObjects/ 
> MyApplication), be it direct action or component action.

// the following should do it.
// bear in mind that the servletURL includes WOCGIAdaptorURL
// so you might want to specify your desired adaptor url
// in your Properties file or via JavaMonitor.
//
Appliction.application().servletConnectURL();

Otherwise, if you might use the userInfo dictionary upon dispatching  
the request so you can access it anywhere you've got access to the  
WORequest object. e.g.,
this.context().request().userInfo().valueForKey(Application.APP_URL);

public class Application extends WOApplication {
	private static final Pattern MAIN_URL_PTN = Pattern.compile("^(.*\ 
\.woa)(?:/wa/DirectAction/default.*)$");
	public static final String APP_URL = "appUrl";
	...
	public WOResponse dispatchRequest(WORequest aRequest) {
		WOContext aContext;
		String url;
		Matcher m;

		aContext = new WOContext(aRequest);
		url = aContext.completeURLWithRequestHandlerKey 
(directActionRequestHandlerKey(), "DirectAction/default", "", false, 0);
		m = MAIN_URL_PTN.matcher(url);
		if (m.matches()) {
			aRequest.setUserInfo(new NSDictionary(m.group(1), APP_URL));
		}
		return super.dispatchRequest(aRequest);
	}
}

The front door, so to speak, is dependant on the desired domain of  
deployment. If you're using virtual hosts (which is often the case)  
it's not as simple as detecting the host name of the server running  
the app. So specifying the adaptor url desired for the app is the way  
to go and/or querying the incoming request object...

with regards,
--

Lachlan Deck
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.