What I do is define a static utility function somewhere like this:
/**
* Return a string that represents the fully qualified URL
* for our servlet context, suitable for use in the HTML
* <em>base</em> tag.
*
* <p>As an example, suppose your host was www.mycompany.com,
* you are serving from port 80, and your web application name
* was "opennms," then this method would return:
* <code>http://www.mycompany.com:80/opennms/</code></p>
*
* @param request the servlet request you are servicing
*/
public static String calculateUrlBase( HttpServletRequest request ) {
if( request == null ) {
throw new IllegalArgumentException( "Cannot take null
parameters." );
}
StringBuffer buffer = new StringBuffer();
buffer.append( request.getScheme() );
buffer.append( "://" );
buffer.append( request.getServerName() );
buffer.append( ":" );
buffer.append( request.getServerPort() );
buffer.append( request.getContextPath() );
buffer.append( "/" );
return( buffer.toString() );
}
Then, in my JSP html header, I do this:
<base HREF="<%=my.project.web.Util.calculateUrlBase( request )%>" />
Not the prettiest solution, especially since you have to add that ugly line
to every JSP, but maybe someone will add a standard JSP action for
calculating this in the future. I thought about adding a custom taglib for
doing this, but writing a static method was simpler.
Larry Karnowski
[EMAIL PROTECTED]
http://www.opennms.org/
----- Original Message -----
From: <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, February 20, 2001 2:00 PM
Subject: <BASE href="...."> ?
> Yo,
> a quick and simple question:
> is there a configuration option that adds a base tag to the jsp pages ?
> if there is, where is it ?
>
> TIA,
>
> Sloot.
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, email: [EMAIL PROTECTED]
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, email: [EMAIL PROTECTED]