...

View Full Version : I need JSP if/else help!



123dhs321
06-03-2005, 09:35 PM
How do I do something like below for JSP?

Lets say I have header and footer includes and want to change the title tag per page. Below is what I would do in PHP but I need to know how to do this in JSP.

<title>
<? if ($SubnavLocation == 'HERE') { ?>Something..<? } else if { ?>Something<? } ?>
</title>

This would be inserted into the top of the page I want a title change.
<? $SubnavLocation = 'HERE';?>

Any help would be greatly appreciated.

Thanks,
-Ryan

nikkiH
06-08-2005, 03:21 PM
How do I do something like below for JSP?
Lets say I have header and footer includes and want to change the title tag per page. Below is what I would do in PHP but I need to know how to do this in JSP.
<title>
<? if ($SubnavLocation == 'HERE') { ?>Something..<? } else if { ?>Something<? } ?>
</title>
This would be inserted into the top of the page I want a title change.
<? $SubnavLocation = 'HERE';?>




<title>
<%
if ("HERE".equalsIgnoreCase(SubnavLocation))
{
out.print("something");
}
else
{
out.print("something else");
}
%>
</title>


Though I'd make a little bean to do it, personally, this is easier for newbies. As you progress with JSP, you'll learn that scriptlets in your pages become a huge pain to maintain.
Also note that I made this case-insenstive with equalsIgnoreCase. If you don't need that, just use equals instead.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum