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: <html:base> with examples New page: == <html:base> == 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). ==== Attributes ==== ||<rowstyle="background-color: #FFFFE0;">Attribute||<style="width: 80%">Description||<tablestyle="width: 100%">Type|| ||ref||The reference from which the base uri will created. Possible values are: * page - The base uri will be the jsp page location. (default) * site - The base uri will be the application context path.||String|| ||server||The server name to use instead of request.getServerName().||String|| ||target||The window target for this base reference.||String|| ==== Examples ==== Examples setup: Navigated to action: "http://localhost:8080/myapp/Home.do" Action forwarded to view: "/pages/home.jsp" ==== Example 1: <html:base/> is not specified in home.jsp page, HTML <base> tag is not generated ==== ||||<rowstyle="background-color: #FFFFE0;">||<style="width: 50%">Explanation|| ||<^>Base, assumed by browser||<^>http://localhost:8080/myapp (address of /myapp/Home.do)||After browser navigated to http://localhost:8080/myapp/Home.do location, it received content of home.jsp page in response. From browser's point of view content of home.jsp page is identified by above address. Base tag is not specified, so browser calculates default base location from the address it used to retrieve the resource. Making analogy with filesystem, Home.do is a file located in localhost:8080/myapp directory. Browser uses this "directory" as base for Home.do "file" as well as for other "files".|| ||Root, assumed by browser||http://localhost:8080 (webserver name + port)||Web browser does not have information about applications running on server or about contexts, defined for these applications. From browser's point of view, it read a "file" from http://localhost:8080 "drive".|| ||Expanding relative path||"About.do" --> http://localhost:8080/myapp/About.do||Browser concatenates base and a relative address to produce full address|| ||Expanding absolute path||"/About.do" --> http://localhost:8080/About.do||Browser concatenates root "drive name" with absolute link to produce full address|| ==== Example 2: <html:base/> is specified in home.jsp page ==== ||||<rowstyle="background-color: #FFFFE0;">||<style="width: 50%">Explanation|| ||<^>Generated HTML <base> tag||<^><base href="http://localhost:8080/myapp/pages/home.jsp">||Struts generated <base> tag, setting http://localhost:8080/myapp/pages as base "directory" for relative links. Despite that browser requested Home.do resource, Struts sets base address according to location of home.jsp file.|| ||<^>Base, assumed by browser||<^>http://localhost:8080/myapp/pages (taken from <base> tag)||Because <base> tag is specified, browser calculates default base location from href attribute. Making analogy with filesystem, home.jsp is a file located in localhost:8080/myapp/pages directory. Browser uses this "directory" as base for home.jsp "file" as well as for other "files" with relative URIs.|| ||Root, assumed by browser||http://localhost:8080 (webserver name + port)||Web browser does not have information about applications running on server or about contexts, defined for these applications. From browser's point of view, it read a "file" from http://localhost:8080 "drive".|| ||Expanding relative path||"About.do" --> http://localhost:8080/myapp/pages/About.do||Browser concatenates base and a relative address to produce full address|| ||Expanding absolute path||"/About.do" --> http://localhost:8080/About.do||Browser concatenates root "drive name" with absolute link to produce full address|| ==== Example 3: <html:base/> tag is specified in home.jsp page with optional attributes ==== ||<rowstyle="background-color: #FFFFE0;">Struts <html:base> tag||HTML <base> tag||<style="width: 50%">Explanation|| ||<^><html:base server="myserver"/>||<^><base href="http://myserver:8080/myapp/pages/home.jsp">||Struts substitutes server name in href attribute of <base> tag. This may be useful in test environment or for accessing resources from other website using relative links.|| ||<^><html:base target="myWindow"/>||<^><base href="http://myserver:8080/myapp/pages/home.jsp" target="myWindow>||Activating any link on this page opens a new document in the frame or window with specified name. If window with specified name does not exist, browser will create a new window. See [http://www.w3.org/TR/REC-html40/present/frames.html#adef-target HTML 4.0 specs] for details.|| --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]