Solved

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

Posted on 2004-09-15
8
186 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
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

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

 
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: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

Suggested Solutions

Title # Comments Views Activity
JSP Popup page 2 126
report generation frameworks 1 69
main method of string class 3 117
null output 3 35
Some of the SEO trends we might expect in 2017.
The advancement in technology has been a great source of betterment and empowerment for the human race, Nevertheless, this is not to say that technology doesn’t have any problems. We are bombarded with constant distractions, whether as an overload o…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used.

791 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