Solved

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

Posted on 2004-09-15
8
183 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
Comment Utility
Try this;
<%
if(condition){%>
Will show this part if condition is true
<%}%>
and so on.
--Raj
0
 
LVL 35

Expert Comment

by:TimYates
Comment Utility
> 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
Comment Utility
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
Comment Utility
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
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 
LVL 35

Expert Comment

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

Accepted Solution

by:
TimYates earned 50 total points
Comment Utility
Sorry:

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

I missed a bracket :-/
0
 
LVL 1

Author Comment

by:g118481
Comment Utility
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
Comment Utility
:-)

Thanks, and good luck!!

Tim
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Learn to move / copy / export exchange contacts to iPhone without using any software. Also see the issues in configuration of exchange with iPhone to migrate contacts.
A procedure for exporting installed hotfix details of remote computers using powershell
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

762 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

15 Experts available now in Live!

Get 1:1 Help Now