![]() |
NSAPI Sample Application |
NSAPI Sample Application
This document describes how to utilize the NSAPI sample application in conjunction with Sun ONE Application Server version 7.This sample application document contains the following sections:
- Overview
- Compiling the Sample Applications
- Deploying the Sample Applications
- Running the Sample Applications
- Troubleshooting
Overview
The following instructions describe how to use NSAPI samples.For more details on NSAPI and the samples demonstrated here, please refer to the Developer's Guide to NSAPI. Besides the source code of Custom SAFs provided, we also provide the samples to utilize these SAFs.
Compiling the Sample Applications
Depending on your operating system, choose one of the following two methods to compile the samples.
Once you have created the sample application from scratch, you may proceed to Deploying the Sample Applications .
- Solaris
- Windows 2000
Deploying the Sample Applications
Instructions to deploy the individual sample reside inside the source code. Illustrated here are the steps to deploy all NSAPI samples and run them from a single URL.Init.conf, <server-instance> -obj.conf and mime.types under s1as_install_dir/domains/{domain_instance}/{server_instance}/config should be modified.
The server has to be restarted after the config files modification. If you deploy on W2K, you need to replace .so with .dll .
- Modify init.conf .
- Add the following lines at the end of the file:
- Init fn="load-modules" funcs="hardcoded_auth,explicit_pathinfo,acf_init,restrict_by_acf,html2shtml,send_images,brief_init,brief_log" shlib="s1as_install_dir/samples/nsapi/example.so"
- Init fn=brief_init file="s1as_install_dir/samples/nsapi/src/test/addlogtest"
- Init fn=acf_init file="s1as_install_dir/samples/nsapi/src/test/pathcheck/checkfile"
- Init fn="load-modules" funcs="cgiwatch_init,cgiwatch_service" shlib="s1as_install_dir/samples/nsapi/cgiwatch.so"
- Init fn=cgiwatch_init
- Init fn="load-modules" funcs="qos_error_sample,qos_handler_sample" shlib="s1as_install_dir/samples/nsapi/qos.so" shlib_flags="(global|now)"
- Modify <server-instance> -obj.conf.
- Add the following lines inside the default object just before NameTrans fn=document-root root="$docroot":
- NameTrans fn=pfx2dir from=/nsapi dir="s1as_install_dir/samples/nsapi/src/test"
- NameTrans fn=pfx2dir from=/authtrans dir="s1as_install_dir/samples/nsapi/src/test/authtrans" name="authtrans"
- NameTrans fn=pfx2dir from=/nametrans dir="s1as_install_dir/samples/nsapi/src/test/nametrans" name="nametrans"
- NameTrans fn=pfx2dir from=/pathcheck dir="s1as_install_dir/samples/nsapi/src/test/pathcheck" name="pathcheck"
- NameTrans fn=pfx2dir from=/objecttype dir="s1as_install_dir/samples/nsapi/src/test/objecttype" name="objecttype"
- NameTrans fn=pfx2dir from=/service dir="s1as_install_dir/samples/nsapi/src/test/service" name="service"
- NameTrans fn=pfx2dir from=/addlog dir="s1as_install_dir/samples/nsapi/src/test"
- NameTrans fn=pfx2dir from=/qos dir="s1as_install_dir/samples/nsapi/src/test" name="qos"
- NameTrans fn=assign-name from=/cgiwatch name=cgiwatch stop=true
- Add the following line after AddLog fn=flex-log name="access":
- At the end of the file, add the following lines:
- <Object name="authtrans">
- AuthTrans fn=basic-auth auth-type="basic" userdb=garbage userfn=hardcoded_auth
- PathCheck fn=require-auth realm="test realm" auth-type="basic"
- </Object>
- <Object name="nametrans">
- NameTrans fn=explicit_pathinfo separator=","
- ObjectType fn=force-type type=magnus-internal/cgi
- Service fn=send-cgi user="$user" group="$group" chroot="$chroot" dir="$dir" nice="$nice"
- [In W2K, the send-cgi in the previous line should be replaced by send-shellcgi]
- </Object>
- <Object name="pathcheck">
- PathCheck fn=restrict_by_acf
- </Object>
- <Object name="objecttype">
- ObjectType fn=html2shtml
- ObjectType fn="shtml-hacktype"
- Service fn="parse-html" method="(GET|HEAD)" type="magnus-internal/parsed-html"
- </Object>
- <Object name="service">
- Service method=(GET|HEAD) fn=send_images type=magnus-internal/picgroup
- </Object>
- <Object name="cgiwatch">
- Service method=(GET|HEAD) fn=cgiwatch_service
- </Object>
- <Object name="qos">
- AuthTrans fn="qos_handler_sample"
- Error fn="qos_error_sample" code="503"
- </Object>
- Modify mime.type.
Running the Sample Applications
The following steps should be performed in order to run the samples:
- Before you run the qos sample, you have to enable the qos from Admin server:
- Click on HTTP Server from the left pane.
- Click on QOS from the right pane.
- Enable the QOS.
- Set Bandswidth Limit to 50 and enable the "Enforce Bandwidth Limit" .
- Apply the Change.
- In order to run Service, do the following:
- copy s1as_install_dir/samples/docs/images/SunONE.jpg to s1as_install_dir/samples/nsapi/src/test/service
- In order to run NameTrans on Solaris, do the following:
- In order to run NameTrans on Windows 2000, do the following:
- Modify nametrans.cgi inside s1_as_install_dir/samples/nsapi/src/test/nametrans, replace env with set .
- Go to My Computer -> Tools -> Folder Options -> File Types, add the new file type cgi , add the perl interpretor.
- The user who performed the previous step should be the same user who started the app server.
The URL to access all the samples is: http://<AppServer hostname>:<port>/nsapi
Table 1 explains the functionality of each.
- If you encounter problems when running the application, review the log files at s1as_install_dir/domains/<domain-instance> /<server-instance>/logs/server.log to learn what exactly went wrong.
- If you use Internet Explorer, the Service link does not work since the file with the content type multipart/x-mixed-replace is not supported in Internet Explorer.
Copyright © 2002 Sun Microsystems, Inc. All rights reserved.
Last Updated August 13, 2002