Solved

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

Posted on 2004-09-15
8
184 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
 
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
The new Gmail Phishing Scam going around is surprising even the savviest of users with its sophisticated techniques. This attack comes as a nightmare trifecta for email filtering services; sent from a familiar contact, using authentic tone and verbi…
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

863 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now