|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
evaluating jsp code within a jsp string
So heres the deal, I've got content in a sql table containing a custom tag (taglib), I return this data to a jsp, but I cannot get the jsp to parse the tag...
Any help would be appreciated! Thanks Here's a better example: <% String tag = "<first:helloparam name=\"Diggz\"/>"; out.println(tag); %> How do u get that to work?
__________________
Dave Pedowitz |
|
#2
|
|||
|
|||
|
Using beans would be a better solution
Mark
__________________
100 trillion calculations per nanosecond |
|
#3
|
|||
|
|||
|
Could u please elaborate?
|
|
#4
|
|||
|
|||
|
Jsp is a server side scripting language...only webservers can interpret these tags...and out.println is used to print values into webbrowser and webbrowsers cannot interpret these tags...
|
|
#5
|
|||
|
|||
|
I understand all that, but is there a way to evaluate that code... Please see my original post, on what the real question is, the other is just an example...
|
|
#6
|
|||
|
|||
|
did anyone find a solution to this ? I have a similar problem ...
|
|
#7
|
|||
|
|||
|
I never did
![]() |
|
#8
|
|||
|
|||
|
As far as I know you cannot output jsp taglib tags in a scriptlet. However, you can use runtime expressions for your taglib tags.
So, even though this won't work Code:
<% String someVar = "Diggz"; String tag = "<first:helloparam name=\"" + someVar + "\"/>"; out.println(tag); %> This will Code:
<% String someVar = "Diggz"; %> <first:helloparam name='<%= someVar %>'/> With the example you gave, what you are doing does not make sense for reasons I just pointed out. If you post your real code I may be able to give you more specific help. |
|
#9
|
|||
|
|||
|
Ya, it'd be really difficult to write something that would compile a JSP and then try to compile a tag... but it might be possible using say XSL...
My original idea was it'd be cool if you could store data such as: " this is stored in a table <taglib do="stuff"> " and the taglib would also do something dynamic |
|
#10
|
|||
|
|||
|
Same problem here
I am using a custom lag library in which when the tag that I am using is decoded becomes a URL depending on the parameters. Has no one still found a way to do:
Sting temp = <test:URL render="Test" /> I have tried to put this through URLencoder and URLdecoder but it comes out the same, it is not decoded. Any help would be very appreciated. |
|
#11
|
|||
|
|||
|
I have already pointed out that what you are doing is unnecessary. Why do you have to have a string variable evaluated to a jsp tag when a jsp tag will take variables?
|
|
#12
|
|||
|
|||
|
The tag I need decoded in the JSP creates a URL which I need to use to in my JSP to create a PDF of what the HTML page is showing. It is someone else's tag and I haven't dealt with them so I do not know how or where to modify it. I assume custom tags are server side as well as the JSP but are they run before or after the JSP is compiled?
|
|
#13
|
|||
|
|||
|
I believe tags are converted over to java code at compile time. You cannot dynamically output jsp tags using code because of this, but you can do something like this:
Code:
<% String temp = "www.ThisIsSomeUrlFromSomewhere.com"; %> <test:URL render="<%= temp %>" /> The tag will be replaced by the compiler at compile time with the appropriate java code and the variable "temp" will be used for the render attribute. This is assuming the tag is set up to accept runtime values. If you are not sure what those are, I suggest a taglib tutorial. http://java.sun.com/products/jsp/tu...brariesTOC.html |
|
#14
|
|||
|
|||
|
I will take a look at the tutorial, thank you for the link. But first I just wanted to clarify my situation better because what you are suggesting really wouldn't work. I am using someone elses custom tag, I don't want to edit it, I am sure if I could edit it I could set a variable somewhere but I can't (yet, maybe the tutorial will help). And this custom tag creates a URL to the output stream which I want to use in my JSP code on the same page. The way you would use the tag is <img src='<imgURL blah />'> but I need the URL inside my code. Let me take a look at that tutorial now, but if you understand better and know a solution please feel free to let me know, thank you.
|
|
#15
|
|||
|
|||
|
Thanks so much Nemi, that tutorial did the trick, I just needed to know how the Tag Handler was Invoked and I was able to manipulate that to get what I wanted, thanks!
|
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Java Help > evaluating jsp code within a jsp string |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|