Solved

Dynamic Include variable

Posted on 2004-09-24
6
443 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
Comment Utility
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
Comment Utility
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
Comment Utility
You can try
                        
<jsp:include pagetest.jsp" flush="true">
<jsp:param name="stage" value="<%=stage%>" />
</jsp:include>
0
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 7

Expert Comment

by:CajunBill
Comment Utility
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
Comment Utility
<jsp:include page="test.jsp" flush="true">
       <jsp:param name="stage" value="<%=stage%>"/>
         </jsp:include>
0
 
LVL 1

Expert Comment

by:KartikShah
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
File names with & character 6 59
CSS HELP 6 73
Specific format 21 139
How to get statistic's from a competitors website?! 1 42
I will show you how to create a ASP.NET Captcha control without using any HTTP HANDELRS or what so ever. you can easily plug it into your web pages. For Example a = 2 + 3 (where 2 and 3 are 2 random numbers) Session("Answer") = 5 then we…
JavaScript has plenty of pieces of code people often just copy/paste from somewhere but never quite fully understand. Self-Executing functions are just one good example that I'll try to demystify here.
The viewer will learn how to dynamically set the form action using jQuery.
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…

728 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now