Thanks very much to all who replied!

The suggestions based on requiring jspx as the jsp-file format are unfortunately not possible. That's too much to require of users of the new framework. And non-xml jsp is really hard to parse. So I think that the suggestions involving scanning the .jsp myself are not going to be feasable.

And "sordid container-specific hacks" are not really tempting either ;-). As there doesn't seem to be any reasonably portable solution, I'll take Bill and Mikolaj's advice and drop this idea (ie only support metadata via companion .xml files).

I might propose the idea of "jsp metadata" to the jsp group for the next spec version though. It seems to me that all that is really missing is an api something like RequestDispatcher.getServletClass() to get the class that will handle the url that the RequestDispatcher wraps. Then it would be possible to get the class of the servlet generated from the jsp. Hmm..in the case of jsp, this would need to return not the "JspServlet" that compiles the jsps, but the generated class, so it's not trivial. There's probably a solution somewhere though..

Thanks again,
Simon

Bill Barker schrieb:
As Mikolaj pointed out, there is absolutely no way to do this that will be compatible across containers.

And, even for Tomcat only, this isn't going to be easy. Tomcat (or, more correctly Jasper) doesn't publish this information in any form that can be reliably read (e.g. JMX). Partially this is because the class name may change if you are running in developement mode (where it re-compiles changed JSP pages on the fly).

I can think of various sordid container-specific hacks based on getClassLoader().getResources(...), but I'm sure that you can think of them too ;). If this was for one webapp, then I'd just pre-compile all the JSP pages before deploying, and have a catalog that maps servlet-path to classname. For a framework, I can't think of anything better than a ResponseWrapper that handles requests with reserved query-strings. But this is ugly enough, that personally I'd just stick with the separate .xml file.

"Simon Kitching" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED]
Mikolaj Rydzewski schrieb:

Simon Kitching wrote:
Or perhaps someone can suggest an alternate approach to embedding metadata that can be accessed before the page renders?
Please provide as with more details, at this point your requirement is a little bit strange. Have you considered using filters?

Ok, here are some more details.

I'm working on the myfaces orchestra flow project (for JavaServer Faces, aka JSF). It allows one JSF page to "call" another JSF page like a subroutine, passing parameters and allows the called page(s) to simply "return" to the page that called them, passing back results. This makes navigation between pages easier, makes the data passing explicit, and avoids any potential variablename "collisions" by setting up a completely clean scope for the called page to run in, with only the passed variables visible.

When a "call" to a page is done, the page from which the call is made must declare metadata about what the parameters to be passed are, and what logical "service" the called page provides. The called page also needs to declare what input parameters it expects, and what logical service it provides. Think of this like a Java method "prototype" (which is also metadata, and can be queried via java reflection).

The code where this metadata is needed is in a JSF ViewHandler, which is indirectly called from the JSF FacesServlet class, after the user has submitted a form. The metadata is used for sanity-checking of the call and setting up of the passed parameters (rearrangement of variables in the http session scope etc). Then a forward to the "called" page is done.

As described in the original email, this is currently done by looking for a ".xml" file sitting beside each .jsp. It works ok, and for any JSF view mechanism (jsp, facelets, clay, etc). But some people might find embedding the information in the actual page to be nicer to work with. Doing this with Facelets isn't too hard, but embedding the necessary info into a jsp page is straining my jsp knowledge considerably :-) However I think the issue is a generic one, not anything specific to this particular case: I want to add "metadata" to a jsp page, just like java annotations provide static metadata about a class without needing to create an instance and execute it. I would think that being able to "annotate" a jsp would be useful for many purposes.

Regards,
Simon


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

Reply via email to