Solved

Dynamic Include variable

Posted on 2004-09-24
6
455 Views
Last Modified: 2013-11-18
I want to pass a dynamic parameter to an include:
<%
String stage = request.getParameter("primaryComp");
%>

<jsp:include page="test.jsp?stage=<%=stage%>" flush="true"/>

/////////////////////
but this doesn't work? Any ideas?? The parameter is being passed in. I also tried:
////////////////////

 <jsp:include page="integrityTrust.jsp" flush="true"/>
 <jsp:param name="stage" value="<%=stage%>"/>
  </jsp:include>

And I still get null for the value in the include. Even if I change the value to something static:

 <jsp:param name="stage" value="test"/>


I'm calling the value in the include as so:

String stage = request.getParameter("stage");
0
Comment
Question by:894359
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 14

Expert Comment

by:sudhakar_koundinya
ID: 12149128
this will not work

i will give it in 5 mins. bear with me
0
 
LVL 14

Accepted Solution

by:
sudhakar_koundinya earned 500 total points
ID: 12149243
check this
<jsp:include page="test.jsp" flush="true">
       <jsp:param name="stage" value="<%=stage%>">
</jsp:param>
         </jsp:include>
0
 

Expert Comment

by:yan_er04
ID: 12151172
You can try
                        
<jsp:include pagetest.jsp" flush="true">
<jsp:param name="stage" value="<%=stage%>" />
</jsp:include>
0
Independent Software Vendors: 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 7

Expert Comment

by:CajunBill
ID: 12153419
Howdy 894,

Two things:
1. try leaving off the closing "/" in the jsp:param.  In other words, use
<jsp:include page="integrityTrust.jsp" flush="true"/>
 <jsp:param name="stage" value="test">
  </jsp:include>

2. In the include, access the value in HTML (not JSP) by
${param.stage}

You had a good idea in using static data to test with.  See if you can get it working at all using the static data before moving on to your real intent.

HTH, Cajun
0
 
LVL 14

Expert Comment

by:sudhakar_koundinya
ID: 12153440
<jsp:include page="test.jsp" flush="true">
       <jsp:param name="stage" value="<%=stage%>"/>
         </jsp:include>
0
 
LVL 1

Expert Comment

by:KartikShah
ID: 12169330
Try using the include directive i.e.

<%@include file="integrityTrust.jsp" %>

Using this, you will not not need to pass the variable, since it is a compile time include, the variable stage declared by you will be directly accessible in the include page. :)

Kartik
0

Featured Post

Enroll in May's Course of the Month

May’s Course of the Month is now available! Experts Exchange’s Premium Members and Team Accounts have access to a complimentary course each month as part of their membership—an extra way to increase training and boost professional development.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to replace a token in a string with square brackets? 2 99
Fixed div within Bootstrap carousel item 11 62
Windows Tool to Build Android and iOS App 3 145
null output 3 54
There are two main kinds of selectors in CSS: One is base selector like h1, h2, body, table or any existing HTML tags.  For instance, the following rule sets all paragraphs (<p> elements) to red: (CODE) CSS also allows us to define our own custom …
I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

740 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