Hello,

just finished a major piece of development in jservssi.
The code now handles some of the ordinary SSI directives such as 
<!--#flastmod file="index.html" --> beside the <SERVLET> tag.
I've also fixed some bugs.

I'd like to become a developer (= get write access to CVS) to
commit all the changes / new files. There are a lot -- see the details
below. 
I'm pretty sure that the changes don't hurt people who only use
<SERVLET> tags. You can test this, just get the code at 

http://lsewww.epfl.ch/urban/jservssi.tgz

The implementation of the SSI directives is far from being perfect,
but it's a lot better than no support at all... but I'll continue
enhancing it.

Peter

--
URBAN Peter                       Mail:  [EMAIL PROTECTED]
Federal Institute of Technology   WWW:   http://lsewww.epfl.ch/urban
EPFL-DI-LSE, office INF 233       Phone: (+41 21) 693 5354
CH-1015 Lausanne, Switzerland     Fax:   (+41 21) 693 6770

----------

List/explanation of changes/additions:

I started from the head of the jservssi_1_1-DEV branch
(state on 14 May 1999, 12:00 GMT).

? src/java/org/apache/servlet/ssi/EchoTagHandler.java
? src/java/org/apache/servlet/ssi/FLastModTagHandler.java
? src/java/org/apache/servlet/ssi/ConfigTagHandler.java
? src/java/org/apache/servlet/ssi/FSizeTagHandler.java
? src/java/org/apache/servlet/ssi/IncludeTagHandler.java

New tag handlers for the SSI directives
echo, flastmod, config, fsize and include.

? src/java/org/apache/servlet/ssi/SSITagHandler.java

Superclass for all of the SSI tag handlers.

? src/java/org/apache/servlet/ssi/SSIContext.java

Placeholder for info related to one interpretation of a page.
(e.g. #config modifies the date format field of SSIContext,
and a subsequent #flastmod accesses it)

? src/java/org/apache/servlet/ssi/SpecialTagHandlerWithContext.java

Such classes are passed the SSIContext during the interpretation
of the page.

? src/java/org/apache/servlet/ssi/DelegateHttpServletRequest.java

Helper class. #include uses it.
(#include calls the servlet SSI for the included file, with
a derived class of DelegateHttpServletRequest.)

Index: src/java/Makefile
===================================================================
RCS file: /products/cvs/master/jserv_ssi/src/java/Attic/Makefile,v
retrieving revision 1.1.2.2
diff -r1.1.2.2 Makefile
16,25c16
<       org/apache/servlet/ssi/ExampleTagHandler.class          \
<       org/apache/servlet/ssi/HREFParameterPropagator.class    \
<       org/apache/servlet/ssi/PageParser.class                 \
<       org/apache/servlet/ssi/SSIHttpServletResponse.class     \
<       org/apache/servlet/ssi/SSIOutputStream.class            \
<       org/apache/servlet/ssi/ServletTagHandler.class          \
<       org/apache/servlet/ssi/ServletInfoRequest.class         \
<       org/apache/servlet/ssi/SpecialTagHandler.class          \
<       org/apache/servlet/ssi/ParameterPropagatingSSI.class    \
<       org/apache/servlet/ssi/SSI.class
---
>       $(patsubst %.java,%.class,$(wildcard org/apache/servlet/ssi/*.java)) \

I was tired of adding new source files to the makefile.

Index: src/java/org/apache/java/util/SGMLTag.java
===================================================================
RCS file: 
/products/cvs/master/jserv_ssi/src/java/org/apache/java/util/Attic/SGMLTag.java,v
retrieving revision 1.1.2.1
diff -r1.1.2.1 SGMLTag.java
114a115,120
>      * The token that closes this tag.
>      * Different for SSI and SGML tags.
>      */
>     private String closeTag = null;
> 
>     /**
138a145
>     static final String SSI_START = "!--#", SSI_END = "-->";
227,228c234,235
<         input.mark (COMMENT_START.length());
<         num = input.read (buff, 0, COMMENT_START.length());
---
>         input.mark (SSI_START.length());
>         num = input.read (buff, 0, SSI_START.length());
231c238
<         if (!COMMENT_START.equals (cmpStr)) {
---
>         if (SSI_START.equals(cmpStr) || !COMMENT_START.equals(cmpStr)) {
233c240
<           break;         // No comment .. real start of a SGML Tag
---
>           break;         // No comment .. real start of a SGML / SSI Tag
258a266
> 
266a275,281
> 
>       // set the token that closes this tag
>       if (name.startsWith(SSI_START)) {
>           closeTag = SSI_END; // SSI tag
>       } else {
>           closeTag = ">"; // SGML tag
>       }
377c392
<             if (key != null && key.equals(">")) {
---
>             if (key != null && key.equals(closeTag)) {
504a520,534
>       // Inserted for token "-->".
>       // Like a word token, but includes the delimiter ">".
>       else if (c == '-') {
>       do { 
>         token.append((char) c); 
>         input.mark(1);
>         c = input.read(); 
>       } 
>       while (c >= 0 && 
>              !Character.isWhitespace((char) c) && 
>              !isDelimiter((char) c));
>       input.reset();
>       token.append((char) input.read());
>       }
> 

SGMLTag now processes SSI tags (starting with <!--#, ending with -->)
as well as SGML tags.

Index: src/java/org/apache/servlet/ssi/PageParser.java
===================================================================
RCS file: 
/products/cvs/master/jserv_ssi/src/java/org/apache/servlet/ssi/Attic/PageParser.java,v
retrieving revision 1.1.2.1
diff -r1.1.2.1 PageParser.java
310a311,312
>       Object context = createInterpretationContext(file, parts, req);
> 
325a328,332
> 
>         if (part instanceof SpecialTagHandlerWithContext) {
>           ((SpecialTagHandlerWithContext)part).setContext(context);
>         }
> 
347a355,372
>     }
> 
>     /**
>      * creates a context for the interpretation of one page.
>      * This context can be used to hold page specific configuration 
>      * info for SSI tags, or to pass information between SSI tags.
>      * <br>
>      * E.g., <code>#config</code> modifies the date format, 
>      * and a subsequent <code>#flastmod</code> uses this new format
>      * for displaying the modification time.
>      * <br>
>      * The default implementation does nothing.
>      * @see #interpretPage
>      */
>     protected Object createInterpretationContext(File file, Vector parts,
>                                                HttpServletRequest req)
>     {
>       return null;

A context object is passed to the tag handlers during interpretation
s.t. they can exchange data.

Index: src/java/org/apache/servlet/ssi/SSI.java
===================================================================
RCS file: 
/products/cvs/master/jserv_ssi/src/java/org/apache/servlet/ssi/Attic/SSI.java,v
retrieving revision 1.1.2.1
diff -r1.1.2.1 SSI.java
59a60,61
> import java.io.File;
> import java.util.Vector;
223c225,236
<       addTagHandler("SERVLET", "org.apache.servlet.ssi.ServletTagHandler");
---
>       addTagHandler("SERVLET",
>                     "org.apache.servlet.ssi.ServletTagHandler");
>       addTagHandler("!--#ECHO", 
>                     "org.apache.servlet.ssi.EchoTagHandler");
>       addTagHandler("!--#FLASTMOD",
>                     "org.apache.servlet.ssi.FLastModTagHandler");
>       addTagHandler("!--#FSIZE",
>                     "org.apache.servlet.ssi.FSizeTagHandler");
>       addTagHandler("!--#CONFIG",
>                     "org.apache.servlet.ssi.ConfigTagHandler");
>       addTagHandler("!--#INCLUDE",
>                     "org.apache.servlet.ssi.IncludeTagHandler");
228a242,251
>     }
> 
>     /**
>      * Creation of an interpretation context.
>      * @see SSIContext
>      */
>     protected Object createInterpretationContext(File file, Vector parts,
>                                                HttpServletRequest req)
>     {
>       return new SSIContext(file, parts, req, this);

New SSI directives added.

Index: src/java/org/apache/servlet/ssi/ServletTagHandler.java
===================================================================
RCS file: 
/products/cvs/master/jserv_ssi/src/java/org/apache/servlet/ssi/Attic/ServletTagHandler.java,v
retrieving revision 1.1.2.1
diff -r1.1.2.1 ServletTagHandler.java
155,156c155,169
<         if (name != null && value != null)
<           params.put(name, value);
---
>         if (name != null && value != null) {
>             // A servlet can have several parameters of the same
>             // name, therefore the values of param will be String arrays.
>             String[] array;
>             String[] oldArray = (String[])params.get(name);
>             if (oldArray == null) {
>                 array = new String[1];
>                 array[0] = value;
>             } else {
>                 array = new String[oldArray.length+1];
>                 System.arraycopy(oldArray, 0, array, 0, oldArray.length);
>                 array[oldArray.length] = value;
>             }
>             params.put(name, array);
>           }
391c404
<     String value = (String) params.get(name);
---
>     String[] value = (String[]) params.get(name);
393c406
<     return value != null ? value :
---
>     return value != null ? value[0] :
409,410c422,424
<     if (params.containsKey(name)) {
<       String[] these;
---
>     String[] paramStrings = (String[]) params.get(name);
>     String[] these;
>     if (paramStrings != null) {
412,413c426,430
<       these = new String[values.length+1];
<       System.arraycopy(values, 0, these, 1, values.length);
---
>       these = new String[values.length+paramStrings.length];
>       System.arraycopy(values, 0, these, paramStrings.length, values.length);
>       System.arraycopy(paramStrings, 0, these, 0, paramStrings.length);
>       } else {
>       these = paramStrings;
415,417c432,433
<       else these = new String[1];
<       these[0] = (String) params.get(name);
<       values = these;
---
>     } else {
>       these = values;
419c435
<     return values;
---
>     return these;
620c636
<       HttpServlet servlet = (HttpServlet) context.getServlet(className);
---
>       Servlet servlet = context.getServlet(className);

Bug fixes:
- now you can use embedded servlets which are not HttpServlets;
- servlets can be given several parameters with the same name, that is,

  <SERVLET CODE=lse.servlet.EmbeddedPublicationsServlet>
    <PARAM NAME=style VALUE=1>
    <PARAM NAME=keyword VALUE=IMPORTANT>
    <PARAM NAME=keyword VALUE=middleware>
    <PARAM NAME=category VALUE=all>
  </SERVLET>

  now passes _both_ keyword parameters to the EmbeddedPublicationsServlet.




------------------------------------------------------------
To subscribe:    [EMAIL PROTECTED]
To unsubscribe:  [EMAIL PROTECTED]
Problems?:       [EMAIL PROTECTED]

Reply via email to