Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

c:import tag, url value from variable

 
kayal cox
Ranch Hand
Posts: 376
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am using c:import jstl tag to fetch in a remote file.
The url to be used is coming in from a session attribute in the request.

I am able to get it to work if I use it like so:


But if I do this, the import fails.

where urlVariable="http://someurl.com/file.html"

Can't I use a variable with c:import? How can I fix this?

Thanks.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64632
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Think about it for a minute:



references a scripting variable named urlVariable. Yes you say that it's a scoped session variable.

So, how would normally access a scoped session variable?
 
Anthony Watson
Ranch Hand
Posts: 327
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use the Expression Language within the tag like so:

 
kayal cox
Ranch Hand
Posts: 376
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is what happens when I code while having a hangover!
Thanks for taking the time to help me with this trivial question.
 
Chris Staten
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear, are you talking about using the request object?

I would aggree that using EL is cleaner, I just wanted to know.
[ December 13, 2004: Message edited by: Chris Staten ]
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64632
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, I was trying to have kayal come up with the answer that Anthony gave.
 
Anthony Watson
Ranch Hand
Posts: 327
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry Bear, I didn't mean to sabotage your teaching method
 
Maki Jav
Ranch Hand
Posts: 445
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Maybe I am not following you guys correctly but we have been doing things
similar to <c:import url="<%=urlVariable%>" /> all the time but first we have to describe the tags something like...


This allows the expressions like "<%=aVariable%>" to be passed to the tags at runtime.

Am I not correct?

Thanks

Maki Jav
[ December 14, 2004: Message edited by: Maki Jav ]
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64632
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The difference in is in what you are referencing: a scripting variable is quite different from a scoped variable.
 
kayal cox
Ranch Hand
Posts: 376
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And I will never forget the difference again!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic