I would use the Model-View-Control pattern.
First it must be defined a Controller, which is simply Servlet mapped to
catch all the request.
This servlet can read the XML and append your metadata to the request and
forward it to the correct jsp (which will handle your metadata i suppose)
Regards
Luca
--------------------------------------------------
From: "Simon Kitching" <[EMAIL PROTECTED]>
Sent: Tuesday, July 29, 2008 11:04 AM
To: <users@tomcat.apache.org>
Subject: [programmazione] Embedding custom metadata in a jsp page; access
generated Class via reflection?
Hi,
I need to associate some custom metadata with JSP pages, and access it
*before* the page is rendered.
The current implementation uses an xml with the same name as the jsp, eg
foo.jsp
foo.xml
so that when I'm about to forward to "foo.jsp" I first look for a
"foo.xml" file and if present parse it to extract the metadata.
I'd really like to embed that metadata within the jsp page itself - but
need access to that info *before* the jsp page executes.
(a)
Is it possible to obtain the name of the Class that is generated for a
jsp, so that I could do introspection on it?
It would then be possible to embed something like this into the page:
<%!
private static MyMetaData metaData = new MetaData(....);
public static MyMetaData getMetaData() { return metaData; }
%>
and look for/invoke the getMetaData method *before* forwarding to the
page.
Of course, this also requires that the servlet-class for the jsp has
actually been generated. Is there a way to guarantee this is done for any
particular jsp before actually doing a forward?
Note that requiring pre-compilation of all jsps is not an option. This
metadata stuff is needed for an open-source framework, and it is not
reasonable to tell every possible user of this framework to precompile
their jsps.
(b)
If the above is possible, is there a way to generate those static members
from a custom JSP tag? It would be nicer to be able to do:
<myns:declareMetaData ..../>
and have that define the static members listed above.
Or perhaps someone can suggest an alternate approach to embedding metadata
that can be accessed before the page renders?
Thanks,
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]
---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]