It's not a secret anymore!*
The moose likes Struts and the fly likes Variable inside title tag Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Variable inside title tag" Watch "Variable inside title tag" New topic
Author

Variable inside title tag

Lou Pelagalli
Ranch Hand

Joined: Nov 11, 2003
Posts: 150
    
    1
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
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 30929
    
158

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]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Lou Pelagalli
Ranch Hand

Joined: Nov 11, 2003
Posts: 150
    
    1
Thanks Jeanne!

<title><bean:write name="beanName" property="beanField"></title> is exactly what I needed.

Lou
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Variable inside title tag