You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Sandro Boehme <sa...@gmx.de> on 2015/07/19 14:32:26 UTC

programatically manipulating a JSP

Hello,

I have a use case where I have to programatically add HTML and/or 
Scriptlet code to a JSP. It has to be placed beside an HTML tag with a 
known id or at the end or the beginning within an HTML tag with a known id.

I would like to use Jasper 6.0.14 (or a newer version if that helps) but 
I haven't found tests in 
http://svn.apache.org/repos/asf/tomcat/tc7.0.x/trunk/test that come 
close to what I want (didn't check version 6.0.14 though) and I also 
haven't found documentation that I can use to get into the details.
Does it makes sense to use
https://theholyjava.wordpress.com/2011/06/10/hacking-jasper-to-get-object-model-of-a-jsp-page/
as a starting point to get it done or is there a better way to approach 
it in the mean time?
I thought about regExp but it seemed to be too unreliably to me.

Thanks for any advice,

Sandro

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: programatically manipulating a JSP

Posted by Sandro Boehme <sa...@gmx.de>.
Hello again,

just for the archive: It turned out that it worked quite well to use 
Jericho for that.

[1] - http://jericho.htmlparser.net/docs/index.html

Best,

Sandro

Am 19.07.15 um 14:32 schrieb Sandro Boehme:
> Hello,
>
> I have a use case where I have to programatically add HTML and/or
> Scriptlet code to a JSP. It has to be placed beside an HTML tag with a
> known id or at the end or the beginning within an HTML tag with a known id.
>
> I would like to use Jasper 6.0.14 (or a newer version if that helps) but
> I haven't found tests in
> http://svn.apache.org/repos/asf/tomcat/tc7.0.x/trunk/test that come
> close to what I want (didn't check version 6.0.14 though) and I also
> haven't found documentation that I can use to get into the details.
> Does it makes sense to use
> https://theholyjava.wordpress.com/2011/06/10/hacking-jasper-to-get-object-model-of-a-jsp-page/
>
> as a starting point to get it done or is there a better way to approach
> it in the mean time?
> I thought about regExp but it seemed to be too unreliably to me.
>
> Thanks for any advice,
>
> Sandro
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: programatically manipulating a JSP

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Sandro,

On 7/19/15 7:32 AM, Sandro Boehme wrote:
> I have a use case where I have to programatically add HTML and/or 
> Scriptlet code to a JSP. It has to be placed beside an HTML tag
> with a known id or at the end or the beginning within an HTML tag
> with a known id.

Can you do this at the .jsp level, or do you need to modify an
existing compiled JSP file? I guess what I'm asking is whether or not
you have to post-process the tree, or if you can change the way the
output is generated in a more standards-compliant way.

For example, you can use <jsp:include> anywhere in a .jsp and you
don't have to go digging-around in the AST for the JSP compiler, which
is going to be a tough job.

Can you tell us a little more about your use case? We might be able to
give you better ideas.

> I would like to use Jasper 6.0.14 (or a newer version if that
> helps) but I haven't found tests in 
> http://svn.apache.org/repos/asf/tomcat/tc7.0.x/trunk/test that
> come close to what I want (didn't check version 6.0.14 though) and
> I also haven't found documentation that I can use to get into the
> details. Does it makes sense to use 
> https://theholyjava.wordpress.com/2011/06/10/hacking-jasper-to-get-obj
ect-model-of-a-jsp-page/
>
>  as a starting point to get it done or is there a better way to
> approach it in the mean time? I thought about regExp but it seemed
> to be too unreliably to me.

If the output is XHTML (or at least perfectly well-formed "x"-HTML),
then you may be able to use XSLT to post-process the document, but
you'd have to do that for every request since you wouldn't be
modifying the source in any way.

- -chris
-----BEGIN PGP SIGNATURE-----
Comment: GPGTools - http://gpgtools.org

iQIcBAEBCAAGBQJVrTn4AAoJEBzwKT+lPKRY7l4P/j//PvbXilKatDZJRUsrkDo1
e1i7VwL3+uxYY9NSUP/wF095XsaaFqF5oY+SzAtrcZlDpgRKOo/OW1PNmEaoDMbA
NMtND1MzGFnAA2/WRdIR2XRH6eeWPYp2hVYHUCWpLiPZFwoGsc4rT6SaMOEb/vI+
Cy9z+e+wval6V5ZicViFFWtAbxaBG0iRCVftxRw+fnXPI7ik5TVDW4bQAvct/tRK
l5z9ExU/t6LDqOte5WElFe8g7oeitScsTu8+1canw0/7o8TjMIBiJi2MN1gEN7Nr
lGh9XMwvsnNxQ+iNWYP0l1DB0uJyfkzjEWGJWQa7wCd3QKXy/MdcMrvy3A2AGSBo
r4PhA5a/7/iSaDJrxlolEBoJdBIDZoXljOE1i2IsYoIIeyltjRUxOxTbFew9qj8g
LEYyQUEU4HkWOEF6oJvMpSAr9NpzU+8lfCPkOikKySqUvfEu2EI467Suc6gmFJsV
ShQF0O1ubqzRrav+Uhqj4KRt5FbKn+RE8skQTgEphNs8oE2CAQaRbR+JB4rd94tq
GS+U4U+l7xgHgYJF5VyF9Po8f0ickyT7La4AjIWVfFuZstCokf8OSEmB3zypO+xG
rphfc5UR90vy5eSwMrlYDmTMA0bCoIhq+93X/nggGSLMK2w/cxmwq77FuDnCxkNm
xEZo29Y8yL5HRjCysX8/
=r4Lq
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org