Solved

Syntax for IF statement, based upon page <title>My Home Page</title>.

Posted on 2004-09-15
8
187 Views
Last Modified: 2010-04-01
I want to put an If statement into my JSP page that shows/doesn't show parts of the output based on the title of the page.

Any ideas on how the syntax for this would be?
0
Comment
Question by:g118481
  • 4
  • 2
  • 2
8 Comments
 
LVL 11

Assisted Solution

by:raj3060
raj3060 earned 50 total points
ID: 12064739
Try this;
<%
if(condition){%>
Will show this part if condition is true
<%}%>
and so on.
--Raj
0
 
LVL 35

Expert Comment

by:TimYates
ID: 12064785
> output based on the title of the page.

I assume you know the title of the page when you build the JSP?

ie:

<%
    String title = "New page" ;
%>
<html>
    <head>
        <title><%= title %></title>
...

then do as raj3060 suggests :-)
0
 
LVL 11

Expert Comment

by:raj3060
ID: 12065330
I guess he/she is trying to read the title of the page from somewhere and then when particular page we are talking about to put the if condition reads that title, and based on the title want to hide/show stuff on the page, and in that case you need to pass the "title" of the page and then read it in the to be displayed page, and decide what you want to show.
-Raj
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Author Comment

by:g118481
ID: 12065525
Ok, first I need to declare what the page name is and output the string into the title tags:

<% String title = "CMAT" ; %>
<html>
<head>
<title><%= title %></title>

Then state the condition, based on the title name:

<% if(condition){ %>
Will show this part if condition is true
<%}%>

My question now, is what should the syntax for the condition be?
0
 
LVL 35

Expert Comment

by:TimYates
ID: 12065555
<% if( title.equals( "CMAT" ){ %>
   Title Equals CMAT
<%}%>
0
 
LVL 35

Accepted Solution

by:
TimYates earned 50 total points
ID: 12065560
Sorry:

 <% if( title.equals( "CMAT" ) ) { %>
   Title Equals CMAT
<%}%>

I missed a bracket :-/
0
 
LVL 1

Author Comment

by:g118481
ID: 12067427
I am increasing the points to 100, and splitting them between both you guys, as both suggestions were used.
Thanks for the work and time!
0
 
LVL 35

Expert Comment

by:TimYates
ID: 12067943
:-)

Thanks, and good luck!!

Tim
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Enabling the Skype for Business Meeting Scheduler in Hybrid OWA
Direct mail marketing is the act of mailing materials straight to prospective customers. This wide form of marketing is one of the oldest methods of communicating with a geographic based demographic. So is it useful in 2017 and beyond?
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

679 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question