| Author |
Variable inside title tag
|
Lou Pellegrini
Ranch Hand
Joined: Nov 11, 2003
Posts: 105
|
|
Hi, How can I get a variable inside I would like the title bar? For example, the source of this page contains <TITLE>JavaRanch Big Moose Saloon</TITLE>. I would like to use <TITLE>variableName</TITLE> where variableName is filled by the java bean prior to the browser display. Thank You in Advance for Your Help, Lou
|
 |
sreenath reddy
Ranch Hand
Joined: Sep 21, 2003
Posts: 415
|
|
If u r using tiles u can make this a part of ur lay out and give a dynalmic value at the run time and u can retrive in ur jsp using tiles:getAsString tag R its just a mtter of jsp and scriplets u use .If u had populated that in a bean ( better set it in the request ) so in ur jsp in scriplets u can directly say req.getAttribute of thatname seems this is what u r asking for
|
 |
Greg Martin
Greenhorn
Joined: May 13, 2004
Posts: 1
|
|
You could just use regular JSP syntax: <% String someVar = ""; %> <title><%= someVar %></title> or, with the struts tags, you can store your titles in a properties file and use the message tage in the struts-bean tld. <%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html:html locale="true"> <head> <html:base /> <title><bean:message key="some.page.title"/></title>
|
 |
Jeanne Boyarsky
internet detective
Marshal
Joined: May 26, 2003
Posts: 23635
|
|
Lou, If you want to do it in pure struts (without scriptlets) : or
|
[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Certs: SCEA Part 1, Part 2 & 3 & Core Spring 3, OCAJP
|
 |
Lou Pellegrini
Ranch Hand
Joined: Nov 11, 2003
Posts: 105
|
|
Thanks Jeanne! <title><bean:write name="beanName" property="beanField"></title> is exactly what I needed. Lou
|
 |
 |
|
|
subject: Variable inside title tag
|
|
|