PDA

View Full Version : Generating web URL from business layer


msqr
Oct 1st, 2004, 12:26 PM
I need to send emails after certain events in my application, and in those emails include a URL that points to an application URL. For example, when a user registers for an account, I send them an email with a confirmation URL in it so they can activate the account. The emails are sent via a method interceptor on the business layer.

My question is: what is the best way to access the web-context specific information from the business layer? I would like not to have to code in the web context or web controller if possible. Currently I just use a property like

my.url=http://foo.bar/thing

but wondered if there was perhaps a better way?

Colin Sampaleanu
Oct 3rd, 2004, 09:54 AM
I think the cleanest way is for your web layer to pass in the URL down to your service/business layer. Your business layer knows nothing about anything above it, after all...

But I wouldn't hard-code the host, port, context etc. The web layer should just get these from the current request, and then tack on a context relative portion which is a property being set in the appcontext.