File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSP and the fly likes c:import tag, url value from variable Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "c:import tag, url value from variable" Watch "c:import tag, url value from variable" New topic
Author

c:import tag, url value from variable

kayal cox
Ranch Hand

Joined: Aug 19, 2004
Posts: 376
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

Joined: Jan 10, 2002
Posts: 61010
    
  65

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?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Anthony Watson
Ranch Hand

Joined: Sep 25, 2003
Posts: 327
Use the Expression Language within the tag like so:



Anthony W.<br />MCP, SCJP 1.4, SCJD, SCWCD 1.3, SCWCD 1.4, SCBCD
kayal cox
Ranch Hand

Joined: Aug 19, 2004
Posts: 376
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

Joined: Sep 24, 2004
Posts: 101
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

Joined: Jan 10, 2002
Posts: 61010
    
  65

No, I was trying to have kayal come up with the answer that Anthony gave.
Anthony Watson
Ranch Hand

Joined: Sep 25, 2003
Posts: 327
Sorry Bear, I didn't mean to sabotage your teaching method
Maki Jav
Ranch Hand

Joined: May 09, 2002
Posts: 435
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 ]

Help gets you when you need it!
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61010
    
  65

The difference in is in what you are referencing: a scripting variable is quite different from a scoped variable.
kayal cox
Ranch Hand

Joined: Aug 19, 2004
Posts: 376
And I will never forget the difference again!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: c:import tag, url value from variable