Dear Wiki user, You have subscribed to a wiki page or wiki category on "Struts Wiki" for change notification.
The following page has been changed by MichaelJouravlev: http://wiki.apache.org/struts/StrutsTaglibHtmlBase The comment on the change is: Explained how <base> is built from request artifacts ------------------------------------------------------------------------------ Renders an HTML <base> element with an href attribute pointing to the absolute location of the enclosing JSP page. This tag is valid only when nested inside an HTML <head> element. This tag is useful because it allows you to use relative URL references in the page that are calculated based on the URL of the page itself, rather than the URL to which the most recent submit took place (which is where the browser would normally resolve relative references against). + + While HTML <base> tag does additional processing of request elements, its basic functionality boils down to the following expression: + {{{ + <base href=" + <%= request.getScheme()+ + "://"+request.getServerName()+":"+ + request.getServerPort()+ + request.getRequestURI() + %>"> + }}} + + Note: if you access an action from the browser and then forward to a JSP page, then you can use request.getRequestURL() to obtain address of the action, and request.getRequestURI() to obtain address of the JSP page. For example, consider that the action is defined in struts-config.xml as "/Home", JSP page is stored in directory "pages" as "home.jsp" and context is defined as "myapp". The results obtained from JSP page will be similar to the following: + {{{ + request.getRequestURL() ==> http://myserver:8080/myapp/Home.do + request.getRequestURI() ==> /myapp/pages/home.jsp + }}} ==== Attributes ==== @@ -15, +31 @@ ==== Examples ==== - Examples setup: + Example: - Navigated to action: "http://localhost:8080/myapp/Home.do" + Browser navigates to the action: "http://localhost:8080/myapp/Home.do" - Action forwarded to view: "/pages/home.jsp" + Action forwards to the view: "/pages/home.jsp" ==== Example 1: <html:base/> is not specified in home.jsp page, HTML <base> tag is not generated ==== --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
