Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Variable inside title tag

 
Lou Pelagalli
Ranch Hand
Posts: 150
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 415
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 34375
346
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Lou,
If you want to do it in pure struts (without scriptlets) :

or
 
Lou Pelagalli
Ranch Hand
Posts: 150
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Jeanne!

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

Lou
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic