You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by MartinV <wu...@gmx.net> on 2008/05/29 21:11:52 UTC

modify requested resource before compiling

Hi list,
I've got a task to solve and I don't have any clue where to start. Here's
the chain for delivering a resource like a JSP file to client.

1)Client => 2)Request => 3)Modify Resource => 4)Normal Handling like
JSP-Compiling => 5)Response => 6)Client

I need to modify the needed resource before handling within the jsp
compiler. The best would be to read the file, modify it and than pass it
(maybe as a stream) to the compiler but it seems that it wouldn't work. At
first I thought about Filters but I could apply them only after the
compiling process.
I hope that anyone has an idea/hint for me where to look/what to do or
otherwise could tell me that I'm barking up the wrong tree and it is for
sure not possible to modify the file before handling it.

Thank you very much.
Martin
-- 
View this message in context: http://www.nabble.com/modify-requested-resource-before-compiling-tp17543665p17543665.html
Sent from the Tomcat - User mailing list archive at Nabble.com.


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


Re: modify requested resource before compiling

Posted by Pid <p...@pidster.com>.
So...


If you want to transform some XML into some different XML?
"XSLT, which is a language for transforming XML documents into other XML 
documents."
http://www.w3.org/TR/xslt



If your 'other namespace' is just a generic placeholder, you could make 
it match the namespace of a Tag Library (which you would write to output 
what you need).

javax.servlet.jsp.tagext.SimpleTagSupport is quite easy to work with.


p




MartinV wrote:
> Hi chris,
> thanks for your reply!
> 
> 
> Christopher Schultz-2 wrote:
>> Martin,
>>
>> MartinV wrote:
>> | Hi list,
>> | I've got a task to solve and I don't have any clue where to start.
>> Here's
>> | the chain for delivering a resource like a JSP file to client.
>> |
>> | 1)Client => 2)Request => 3)Modify Resource => 4)Normal Handling like
>> | JSP-Compiling => 5)Response => 6)Client
>>
>> Er... huh? You want to modify a JSP on the fly before it gets compiled
>> and run? Okay...
>>
>> ...
>> Maybe you could explain what you're really trying to do and we could
>> suggest an alternative. What you say you're doing is quite... hacky.
>>
> 
> Ok, this modification is a small part of my thesis. The reason why the
> modification is needed is that I have in the JSP - or maybe in HTML files -
> XML tags from an other namespace. These are some placeholders for dynamic
> content I need to insert. A simple example would be:
> 
> <div>
>   <xyz:widget param1="<%= var1%>" param2="<%= var2%>"></widget>
> </div>
> 
> should be converted to
> 
> <div>
>   <ol>
>     <li><%= var1%></li>
>     <li><%= var2%></li>
>   </ol>
> </div>
> 
> How to transfer the resource to the needed output format is easy to do for
> me but like I told a have no clue how to pass the new resource on the fly to
> the server that he could render/compile and deliver it to the client. I also
> get to know that my approach is a kind of hacky - but it's not for a live
> server - only development. So it's not problem when it's hacky or has a bad
> performance. :)
> 
> 
> Christopher Schultz-2 wrote:
>> Why not just modify it on the disk and use reloadable JSPs?
>>
> 
> The reason is that it should be possible to modify not only JSP file but
> also HTML or declarative documents at all.
> 
> 
> 
> Christopher Schultz-2 wrote:
>> | At
>> | first I thought about Filters but I could apply them only after the
>> | compiling process.
>>
>> That doesn't sound right. You can apply a filter before a request is
>> handled (by the JSP servlet) if you want.
>>
> 
> Yes your are alright. I explained wrong :) I mean that the document is read
> and compiled in one process. I know that it's possible to modify the request
> before processing - but I couldn't find a possibility to handle the loaded
> resource before compiling.
> 
> Thanks for the help,
> Martin
> 


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


Re: modify requested resource before compiling

Posted by MartinV <wu...@gmx.net>.
Hi chris,
thanks for your reply!


Christopher Schultz-2 wrote:
> 
> Martin,
> 
> MartinV wrote:
> | Hi list,
> | I've got a task to solve and I don't have any clue where to start.
> Here's
> | the chain for delivering a resource like a JSP file to client.
> |
> | 1)Client => 2)Request => 3)Modify Resource => 4)Normal Handling like
> | JSP-Compiling => 5)Response => 6)Client
> 
> Er... huh? You want to modify a JSP on the fly before it gets compiled
> and run? Okay...
> 
> ...
> Maybe you could explain what you're really trying to do and we could
> suggest an alternative. What you say you're doing is quite... hacky.
> 

Ok, this modification is a small part of my thesis. The reason why the
modification is needed is that I have in the JSP - or maybe in HTML files -
XML tags from an other namespace. These are some placeholders for dynamic
content I need to insert. A simple example would be:

<div>
  <xyz:widget param1="<%= var1%>" param2="<%= var2%>"></widget>
</div>

should be converted to

<div>
  <ol>
    <li><%= var1%></li>
    <li><%= var2%></li>
  </ol>
</div>

How to transfer the resource to the needed output format is easy to do for
me but like I told a have no clue how to pass the new resource on the fly to
the server that he could render/compile and deliver it to the client. I also
get to know that my approach is a kind of hacky - but it's not for a live
server - only development. So it's not problem when it's hacky or has a bad
performance. :)


Christopher Schultz-2 wrote:
> 
> Why not just modify it on the disk and use reloadable JSPs?
> 

The reason is that it should be possible to modify not only JSP file but
also HTML or declarative documents at all.



Christopher Schultz-2 wrote:
> 
> | At
> | first I thought about Filters but I could apply them only after the
> | compiling process.
> 
> That doesn't sound right. You can apply a filter before a request is
> handled (by the JSP servlet) if you want.
> 

Yes your are alright. I explained wrong :) I mean that the document is read
and compiled in one process. I know that it's possible to modify the request
before processing - but I couldn't find a possibility to handle the loaded
resource before compiling.

Thanks for the help,
Martin

-- 
View this message in context: http://www.nabble.com/modify-requested-resource-before-compiling-tp17543665p17552140.html
Sent from the Tomcat - User mailing list archive at Nabble.com.


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


Re: modify requested resource before compiling

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

Martin,

MartinV wrote:
| Hi list,
| I've got a task to solve and I don't have any clue where to start. Here's
| the chain for delivering a resource like a JSP file to client.
|
| 1)Client => 2)Request => 3)Modify Resource => 4)Normal Handling like
| JSP-Compiling => 5)Response => 6)Client

Er... huh? You want to modify a JSP on the fly before it gets compiled
and run? Okay...

| I need to modify the needed resource before handling within the jsp
| compiler. The best would be to read the file, modify it and than pass it
| (maybe as a stream) to the compiler but it seems that it wouldn't work.

Why not just modify it on the disk and use reloadable JSPs?

| At
| first I thought about Filters but I could apply them only after the
| compiling process.

That doesn't sound right. You can apply a filter before a request is
handled (by the JSP servlet) if you want.

| I hope that anyone has an idea/hint for me where to look/what to do or
| otherwise could tell me that I'm barking up the wrong tree and it is for
| sure not possible to modify the file before handling it.

Maybe you could explain what you're really trying to do and we could
suggest an alternative. What you say you're doing is quite... hacky.

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkg/FXsACgkQ9CaO5/Lv0PDjJQCgv6vWbWoOGnpjR+nNWptWnrmf
BMYAoMPgMYFDYk0qarU3AIGagYpaTNh3
=nMXX
-----END PGP SIGNATURE-----

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