Meena Vyas

All | DTrace Web Server 7.0 | ACLs Web Server 7.0 | General Web Server 7.0 | HttpCompression Web Server 7.0 | Intrusion Detection Web Server 7.0 | Open Web Server | Reference Deployments of Web Server 7.0 | Reverse Proxy Web Server 7.0 | Security Web Server 7.0 | Troubleshooting Web Server 7.0 | WebDAV Web Server 7.0
« Intrusion detection... | Main | DTrace script to... »
20081024 Friday October 24, 2008

Understanding Sun Java System Web Server 7.0 - for developers

Here are things a developer working on Web Server 7.0 or writing a NSAPI plugin should know  

The latest Sun Java System Web Server  7.0 update 3 download location : http://www.sun.com/download/index.jsp?cat=Web%20%26%20Proxy%20Servers&tab=3&subcat=Web%20Servers
The latest Sun Java System Web Server 7.0 update 3 documentation : http://docs.sun.com/app/docs/coll/1653.3

Bookmark NSAPI configuration guide : http://docs.sun.com/app/docs/doc/820-4843
and Administrator's Configuration File Reference http://docs.sun.com/app/docs/doc/820-4841 (which has interfaces)

Some examples on how to write a plugin for Sun Java System Web Server 7.0

<ws-install-dir>/samples/nsapi has some examples about how to write a custom plugin.


Let me start by explaining the basics of our Web Server first in this blog 

To add your own .so dynamic library 

In magnus.conf configuration file we can load our own .so's  as shown below :

#cat magnus.conf
Init fn="load-modules" shlib="libj2eeplugin.so"

Different request and response processing stages in Sun Java System Web Server 7.0

In Sun Java System Web Server 7.0 there are different stages AuthTrans, NameTrans, PathCheck, ObjectType, Service, Output, Input, Error as given in obj.conf.  More info in http://docs.sun.com/app/docs/doc/820-4841/abvag?a=view . We can even make own function that can be executed in a different stages and add it here in this file.

cat obj.conf
...
<Object name="default">
AuthTrans fn="match-browser" browser="*MSIE*" ssl-unclean-shutdown="true"
NameTrans fn="ntrans-j2ee" name="j2ee"
NameTrans fn="pfx2dir" from="/mc-icons" dir="/opt/ws/lib/icons" name="es-internal"
PathCheck fn="uri-clean"
PathCheck fn="check-acl" acl="default"
PathCheck fn="find-pathinfo"
PathCheck fn="find-index-j2ee"
PathCheck fn="find-index" index-names="index.html,home.html,index.jsp"
ObjectType fn="type-j2ee"
ObjectType fn="type-by-extension"
ObjectType fn="force-type" type="text/plain"
Service method="(GET|HEAD)" type="magnus-internal/directory" fn="index-common"
Service method="(GET|HEAD|POST)" type="*~magnus-internal/*" fn="send-file"
Service method="TRACE" fn="service-trace"
Error fn="error-j2ee"
AddLog fn="flex-log"
</Object>

<Object name="j2ee">
Service fn="service-j2ee" method="*"
</Object>

...
<Object name="compress-on-demand">
Output fn="insert-filter" filter="http-compression"
</Object>

Filters

In Web Server we can insert filters like NSPR I/O layer. Filters enable functions to intercept and possibly modify data sent to and from the server. More info is in : http://docs.sun.com/app/docs/doc/820-4843/abvek?a=view . There are two types of filters Input and Output.

Some important Structures in Sun Java system Web Server 7.0

Sun Java System Web Server 7.0 has Request structure http://docs.sun.com/app/docs/doc/820-4843/abvmz?l=en&a=view . It has 4 pblock s which stores data in key and value pairs. More information is given in http://docs.sun.com/app/docs/doc/820-4843/abvmv?l=en&a=view

typedef struct{
    */Server working variables */
    pblock *vars;

    /* The method, URI, and protocol revision of this request */
    pblock *reqpb;

    /* Protocol specific headers */
    int loadhdrs;
    pblock *headers;

    /* Server's response headers */
    int senthdrs;
    pblock *srvhdrs;

    /* The object set constructed to fulfill this request */
    httpd_objset *os;
} Request;

We can print these pblocks by INTpblock_pblock2str(rq-><pblockname>, NULL);. All request headers will be parsed and put into headers pblock. Response headers will be put into srvhdrs pblock.

Memory Management

Every request has its own memory pool which gets freed automatically. So we should call MALLOC , FREE, STRDUP etc. rather than malloc, free, and strdup. Posted by meena ( Oct 24 2008, 02:30:19 PM IST ) Permalink Comments [0]

Trackback URL: http://blogs.sun.com/meena/entry/understanding_sun_java_system_web
Comments:

Post a Comment:

Name:
E-Mail:
URL:

Your Comment:

HTML Syntax: NOT allowed

This blog copyright 2009 by meena

Calendar

Search

RSS Feeds

Navigation

Referers