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?

Darin Wilson
[EMAIL PROTECTED]
http://www.doughnet.com/



-----Original Message-----
From: A mailing list about Java Server Pages specification and reference
[mailto:[EMAIL PROTECTED]]On Behalf Of Jean-Michel Leon
Sent: Wednesday, August 25, 1999 4:03 PM
To: [EMAIL PROTECTED]
Subject: Re: passing parameters from one jsp to another (tms)

Yup, I've been using the include directive for quite a while, for
breaking out applications into components. the problem, when you do
that, is that it becomes unamanagable very easily, because of the lack
of static checking. when you start having a lot of small jsp files (I
call them .jsc for Java Server Components - it is chunks of jsp files
that cannot be used as standalone pages), it is very difficult to keep
track of who's using what.

--- snip ---


Ideally, what I would like is to be able to package these components
into a standalone component, that can be statically checked; something
like:

header.jsc:

<%some kind of directive to say "this is a component, not a page"%>
<%param String title>

<HTML>
<HEAD>
<TITLE><%=title%></TITLE>
...
</HEAD>

and then in page.jsp, I'd do:

<BLAH>
<%include component=header.jsc "this is the title"%>


This could be resolved at compile time (I don't want any runtime
overhead) into java method calls (very approximate description):

// header.jsc
void _jsp_header(JSPWriter out, String title) {
    out.write("<HTML>
        ...
}

//_jspService(...) {
    out.write("<BLAH>");
    _jsp_header(out, "this is the title");
    ...
}


then I would have fully types JSP components; and I would be soooo
happy.

any idea, how I could get close to that (hacks accepted) ?



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

===========================================================================
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