Solved

Dynamic Include variable

Posted on 2004-09-24
6
449 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
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
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 
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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Suggestion on WebSite Template Sites 6 100
How to replace a token in a string with square brackets? 2 68
Fixed div within Bootstrap carousel item 11 58
React or Angular? 6 71
When you work with shopping cart / ecommerce relates web sites, you need to pass the certain form post details to the payment gateway process page with required details for the products items you give to order. Also you may need to track the ordered…
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 learn how to dynamically set the form action using jQuery.
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…

808 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