Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2004-09-15
8
Medium Priority
?
191 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 200 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
Technology Partners: 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 200 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

[Webinar] Cloud Security

In this webinar you will learn:

-Why existing firewall and DMZ architectures are not suited for securing cloud applications
-How to make your enterprise “Cloud Ready”, and fix your aging DMZ architecture
-How to transform your enterprise and become a Cloud Enabler

Question has a verified solution.

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

Did you know there are services out there that can turn an Instagram feed into an RSS feed? I found some interesting exclusive Instagram content which I wanted to follow without signing up for yet another social media account. RSS to the rescue!
Hello there! As a developer I have modified and refactored the unit tests which was written by fellow developers in the past. On the course, I have gone through various misconceptions and technical challenges when it comes to implementation. I would…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Suggested Courses

885 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