aspose file tools*
The moose likes JSP and the fly likes Resolve variables inside a string - JSTL? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Resolve variables inside a string - JSTL?" Watch "Resolve variables inside a string - JSTL?" New topic
Author

Resolve variables inside a string - JSTL?

Mike Alba
Greenhorn

Joined: Jan 04, 2013
Posts: 3
Hi,

I have been trying to figure out if what I am trying is possible using JSTL? I am storing the following inside a table



thus I am storing the following String in a column in a table

"<assign name="LocationID" expr="'${row.locationId}'"/>
<submit next="/aotg/dynApp" namelist="UserID AppID LocationID"/>"


thus the above string for example gets written to ${row.actionText} and gets resolved. But of course the output in the JSTL is exactly as above without resolving
the variable ${row.locationId} inside the String. Can you also somehow resolve the inner variable as well?

Is something like this even possible or do I need to hard code any parameters I might be using inside the JSTL page instead of trying to dynamically read it from
the table?

Thanks so much for any insight!
Mike

Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61413
    
  67

Nope. The time to parse the EL is long past at that point.

You might want to consider a tag file.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Mike Alba
Greenhorn

Joined: Jan 04, 2013
Posts: 3
Hi Bear,

Thanks so much for the quick response! That is what I was thinking. My first thought was to resolve tags inside the String with the proper values and then pass that to the JSP.
Basically have my own pre-parser. As I am new to this and have never used a tag file would learning how to do that be the preferable approach then creating a pre-parser?
And when you say use a tag file do you mean generate a unique dynamic tag file each time I call this code and then use that?

Thanks again!
Mike
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61413
    
  67

For creating a reusable HTML fragment\ with dynamic data, a tag file cannot be beat.
Mike Alba
Greenhorn

Joined: Jan 04, 2013
Posts: 3
Thanks Bear I will need to look into this at a later date as I don't have a lot of time.
For now I just created a map and put the string values and variable values in upfront
and just did string replaces. Sure it is not the most optimal way but will get the job
done until I can research more into tag files...



Thanks
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Resolve variables inside a string - JSTL?