Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

nesting directives in scriptlets

Status
Not open for further replies.

pr0n603

Programmer
Dec 14, 2004
23
0
0
US
The search function is broken again and i apologize if there is another thread answering this question.

I want to conditionally use the include directive in my jsp page (i.e. If a certain variable is true, include jsp1.jsp, else include jsp2.jsp).

something like this
Code:
<% 
   String show_main = (String)request.getAttribute("show_main");
   if (show_main == null) show_main = "false";

Thanks for your help


   //following is what im trying to achieve
   if(show_main.equals("true"))
       <%@ include file="/main.jsp" %>
   else
       <%@ include file="/welcome.jsp" %>

%>
 
I have a jsp page and in that page i have one include directive ( <%@ include file="page_1.jsp" %> ) I want this include directive to be dependent on a certain variable.

so, .... I want to have a specific <%@ include file="filename.jsp" %> for each value of a specific variable. basically,

if variable page_number == 1, i want <%@ include file="page_1.jsp" %>
if variable page_number == 2, i want <%@ include file="page_2.jsp" %>
and so on
 
My O'Reilly Java Server Pages book covers this topic with what looks like a straightforward explanation on pages 315-320.

Off hand it looks like your code should work.

What do you get when you run it?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top