Friday October 24, 2008
Understanding Sun Java System Web Server 7.0 - for developers
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)
<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
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"
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>
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.
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.
This blog copyright 2009 by meena