Darin Wilson wrote:
>
> I quite agree - you can run yourself a little ragged if you go too crazy
> with your includes.
>
> You might be able to do something like what you described with custom tags.
> This hasn't made it into the official JSP spec yet (it was planned for 1.1 -
> I'm not sure if it's there yet or not), but your JSP implementation may have
> some facility for this (I know that JRun does).
>
> With the JRun "taglet" API, you can, among other things, create custom tags
> that are transformed into JSP code at page translation time (there's no
> request time overhead). You could either code the logic into the custom tag
> itself, or, better, create some real Java objects that would do the work
> described in your JSCs, and have the custom tags resolve into calls to those
> objects.
>
> For example, if you created this class like this:
>
> public class JSPComponents extends Object {
>
>         public static writeHeader(Writer out, String title) {
>                 out.write("<HEAD>");
>                 out.write("<TITLE>" + title + "</TITLE>");
>                 out.write("</HEAD>");
>         }
>
>         ...other methods...
> }
>
> You could then create a custom tag that looked like this:
>
> <pageheader title="This is the title"/>
>
> which would, at translation time, turn into this:
>
> <%
>         JSPComponents.writeHeader(out, "This is the title");
> %>
>
> If, later on, you decided you wanted to be able to do something like:
>
> <pageheader title="This is the title" bgcolor="#ffffff"/>
>
> you could add another writeHeader method to the JSPComponents class that
> accepted an extra parameter, and update your "pageheader" custom tag to
> translate into the appropriate method call based on the parameters that were
> passed in. That way, any pages that use the old style won't break.
>
> Is this along the lines of what you had in mind?



so, if I understand, these taglets provide an HTML-ized interface to
method calls. I think that's definitely interesting when you're in an
environment where both artists and programmers modify the same pages. It
is probalby much better accepted by 'artist' tools.

>From my narrow minded programmer's perspective, I still miss the feature
I want: I want to build the writeHeader method as a chunk of JSP (HTML +
Java) code, and not pure Java, whene I have to do all these out.print.

I had a hack idea in mind: with some conventions, it would be pretty
easy to get the JSP compiler generate the java source for the .JSC file,
and then postprocess this file to transform it into a class with a
static method call.

BTW, has anyone been able to statically compile a .jsp into .java with
1.0FCS ? I used to do that with 1.0-ea, and it worked very well, but
now, the com.sun.jsp.compiler.Main class doesn't seem to work anymore.
any hint ?


jm.

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
FAQs on JSP can be found at:
 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html

Reply via email to