ColdCafe ver 1.2



    ColdCafe is a macro-processor servlet. This servlet parses html pages and replaces some predefined elements with their values. It is not a new language like JSP, it is just a set of html-preprocessing that keep your hands free for using any web-authoring tools or development tools(e.g. Frontpage, JavaScript).

    So what is for ? It is yet another tool for dynamic web-pages generation.
These predifined elements are unique session Id, remote host and IP address etc.

    How does it work ?  You pass your page as a parameter for ColdCafe servlet or define appropriate mapping for some selected file extention.

A. Passing page as a parameter.

1) http://your_host/servlet/ColdCafe?page=your_parsed_page
Servlet will generate unique session Id and output preprocessed page

and

2) http://your_host/servlet/ColdCafe?page=your_parsed_page&id=session_id_value
Servlet will output preprocessed page and use 'session_id_value' as a value for the macros @SESSIONID.

Session ID is a some unique value generated during the preprocessing in case this values was not passed as a parameter in the query string. E.g. you can pass first page through preprocessor and use generated values a parameter for any link within this page.

So, for the first page in your project (site) you can point as a
http://your_host/servlet/ColdCafe?page=http://your_first_page_here
and within this page just set all references as a
<a href="http://your_host/servlet/ColdCafe?page=http://your_page&id=@SESSION">

Or ColdCafe parser can automatically replace any href link during the preprocessing and add
id=current_session_id to the query string.

In other words ColdCafe can support some kind of URL rewriting. And unique session Id will be passed a normal GET parameter. So you can have session support through URL rewriting regardless on your engine.

B. Mapping.

For example here we set this servlet invocation for the each file with the extension .cld (it is for JSWDK on NT, see your servletrunner's manual how to define mapping)

.cld=cld

cld.code=ColdCafe

in this case you can just use http://your_host/some_file.cld  and servlet will be called automatically.

The usage of parameters is similar to describes above.

Servlet's parameters.

You can set root directory for files as an initial parameter for servlet. E.g.:

ColdCafe.initparams=root=/home/web/root
 
 

Current tags (macros) are:

@SESSION - unique session Id

@RAND=number1-number2@
random number within the given interval. E.g. @RAND=1-6@ - random number within [1,6]
You can use this for example for setting images(banners). It is some like that:
img src="http://host/dir/name@RAND=1-20@.gif"

@HOST - remote host name
@IP1 - remote IP address
@IP2 - remote IP address
@IP3 - remote IP address
@IP4 - remote IP address

@HH - current hours
@MM - current minutes
@SS - current seconds
@YYYY - current year

@FILE=file_name@
insert named file into output stream

e.g.:

<html>
<br> Session Id: @SESSION
<br> Remote host is @HOST
<br> IP address is @IP1.@IP2.@IP3.@IP4
<br> it is @HH:@MM:@SS of @YYYY
<br> random 1-6 is @RAND=1-6@
<br>  @FILE=/home/java/Session/test.htm@
</html>

Note:
1. If you are using short file names in the FILE macro files will be selected relatively root directory of your servletrunner. Make sure you select proper place for included files or use full path or set root parameter.

2. If the first line of your file is <!-- ColdCafe passed --> such file will passed through servlet transparently (without preprocessing).

For downloading:  ColdCafe.class

 © ColdCafe    Comments?