Two Laptop Bag*
The moose likes JSP and the fly likes Passing parameter to jsp:include with c:set Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Passing parameter to jsp:include with c:set" Watch "Passing parameter to jsp:include with c:set" New topic
Author

Passing parameter to jsp:include with c:set

anfun wong
Greenhorn

Joined: Aug 24, 2006
Posts: 6
How can I pass a parameter using only standard tags (not snipplets) to a dynamically included jsp? Here is what I have tried:

In parent jsp:


In child jsp, when I try to access productId, I got a servlet exception.

Although the following works:
and able to access productId in child JSP.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60785
    
  65

Originally posted by anfun wong:

In child jsp, when I try to access productId, I got a servlet exception.


Do you not think it might be helpful to include the details of said exception?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
anfun wong
Greenhorn

Joined: Aug 24, 2006
Posts: 6
This is for JSP 1.2. Container is WSAD 5.1.2.

Actually just got a little further - no exception now. But the value is not being passed in. It's empty. The code is still the same though, just a server restart.

Thanks!
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60785
    
  65

I assume that you are using JSTL 1.0 as you are using JSP 1.2? (Unless you have a really good reason not to, an upgrade to JSP 2.0/JSTL 1.1 will make you a much happier person).

If so, are you using the _rt JSTL URI's?
anfun wong
Greenhorn

Joined: Aug 24, 2006
Posts: 6
Hi Bear,


If so, are you using the _rt JSTL URI's?


Thanks for the tip. _rt works.
Anfun
Tushar Madhukar
Ranch Hand

Joined: May 03, 2006
Posts: 36
[Bear edit: thread hi-jack removed. Start a new thread for new topics.]
[ September 09, 2006: Message edited by: Bear Bibeault ]
Stefan Evans
Bartender

Joined: Jul 06, 2005
Posts: 1016
Actually I probably would have tried turning the runtime expression <%= productBean.getId() %> into a proper EL expression - ie


[ September 10, 2006: Message edited by: Stefan Evans ]
anfun wong
Greenhorn

Joined: Aug 24, 2006
Posts: 6
Thanks Stefan,

Yes you are right. I did have to use Java because I'm only patching this JSP and the existing variable productBean is not available to the tags.

Is there a good document illustrating the various name spaces involved in JSP and JSTL and how they correlate and interact, and how to communicate variables among them? I have only found pieces of info here and there.

Thanks!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Passing parameter to jsp:include with c:set
 
Similar Threads
using EL in jsp include file
setting attribute using EL
passing var through included jsp to included jsp
using jsp:param
jsp:param - value attribute