7.1 JSP 运行环境
7.1.2 安装和配置 JSWDK
-JRun 连接到特定的服务器
JRun 为用户提供帮助 如果你要了解 JRun 使用的详细信息 在本地便可找到相关的 资料
7.1.2 安装和配置 JSWDK
JSWDK Java Server Web Development Kit 是 SUN 公司为用户提供的一个 JSP/Servlet 调试工具 JSWDK 是一个免费软件 可从 http://java.sun.com 站点下载 下载的软件是一 个ZIP 压缩文件 直接将该文件解压到某个目录 如 c:\jswdk 解压后可在其目录下找 到两个非常重要的文件 webserver.xml 和 startserver.bat webserver.xml 为服务器配置文件 可用浏览器查看其内容 如图7-2 所示
图7-2 webserver.xml 内容 webserver.xml 的源文件内容如下
<?xml version="1.0" encoding="ISO-8859-1"?>
<!--
This file is the default configuration file for the JSWDK server. Following is a brief overview of the JSWDK server configuration options.
========================================================
webserver dtd and xml:
Element Attribute(s) Element(s)
========================================================
WebServer - A collection of web services managed by a
single HTTP Web Server instance.
id - A Unique Web Server id.
adminPort - The Web Server administration port number which is used as an external Web Server hook to invoke administrative tasks such as gracefully shutting down the web server (note: these services are presently not specified and as such are subject to change).
Service - A managed web service.
Service - A distinct web resource which is associated with a fully qualified URI.
id - A unique Service id.
port - The port number with which the Service is registered.
hostName - The system host name in which the Service is hosted.
inet - The system ip address in which the Service is hosted.
docBase - The Service document base.
workDir - The Service work directory.
workDirIsPersistent - Indicator as to whether or not the Web Server should return the associated work directory to the host system upon shut down.
WebApplication - A managed association of web resources.
WebApplication - A collection of associated web resources which correspond to a distinct fully qualified URI.
id - A unique Web Application id.
mapping - The URI prefix with which this Web Application is associated with relative to the hosted Service.
docBase - The Web Application document base.
maxInactiveInterval - The maximum session timeout period.
========================================================
command line options:
configuration attribute details:
All "id" values must be unique with a collection of like elements.
Most configuration values can be declared in one of following three means respectively:
command line webserver.xml configuration.
The JSWDK server will create a default
collection WebServer configuration. Subsequent Service instances specified with duplicate port numbers will fail initialization.
The Server.docBase is the file system location experimental with this release.
The Server.workDir specfies the local file system directory available to the Web Server as needed to
The WebApplication.mapping is used to specify the URI prefix with which this Web Application instance is to be associated with. The specified value of this field must be unique amongst a collection managed by a single Service instance.
This field is likely to be renamed to "path" in a
future release.
The WebApplication.docBase is the file system location which is accessed by the Web Server to service inbound http requests routed to this specific Web Application instance. This field shares many of the attributes specified in the Server.docBase description above.
The WebApplication.maxInactiveInterval is not utilized at this time and will likely specify
<!DOCTYPE WebServer [
<!ELEMENT WebServer (Service+)>
<!ATTLIST WebServer id ID #REQUIRED
adminPort NMTOKEN "90">
<!ELEMENT Service (WebApplication*)>
<!ATTLIST Service id ID #REQUIRED port NMTOKEN "8080"
hostName NMTOKEN "wwwserver"
inet NMTOKEN ""
docBase CDATA "webpages"
workDir CDATA "work"
workDirIsPersistent (false | true) "false">
<!ELEMENT WebApplication EMPTY>
<!ATTLIST WebApplication id ID #REQUIRED
mapping CDATA #REQUIRED
docBase CDATA #REQUIRED maxInactiveInterval NMTOKEN "30">
>
<WebServer id="webServer">
<Service id="service0">
<WebApplication id="examples" mapping="/examples" docBase="examples"/>
<WebApplication id="myjsp" mapping="/myjsp" docBase="myjsp"/> </Service>
</WebServer>
找到其中的
port NMTOKEN "8080"
hostName NMTOKEN ""
docBase CDATA "webpages"
workDir CDATA "work"
等内容 这是用于设置端口号 主机名称 发布目录以及工作目录 这些内容可以由你任
意设定 如果要设置上述内容 可在浏览器中选择 查看源文件 然后修改相应内容
startserver.bat 文件用于启动 JSWDK 服务器 可用记事本将其打开 内容如下
@echo off
rem $Id: startup.bat,v 1.19.2.5 1999/08/31 19:38:43 gonzo Exp $ rem Startup batch file for servlet runner.
rem This batch file written and tested under Windows NT rem Improvements to this file are welcome
set jsdkJars=.\webserver.jar;.\lib\jakarta.jar;.\lib\servlet.jar set jspJars=.\lib\jsp.jar;.\lib\jspengine.jar
set beanJars=.\examples\WEB-INF\jsp\beans;.\webpages\WEB-INF\servlets;.\webpages\WEB-INF\jsp\beans set miscJars=.\lib\xml.jar;.\lib\moo.jar
set appJars=%jsdkJars%;%jspJars%;%beanJars%;%miscJars%
set sysJars=%JAVA_HOME%\lib\tools.jar set appClassPath=.\classes;%appJars%
set cp=%CLASSPATH%
set CLASSPATH=%appClassPath%;%sysJars%
if "%cp%" == "" goto next rem else
set CLASSPATH=%CLASSPATH%;%cp%
:next
echo Using classpath: %CLASSPATH%
start java com.sun.web.shell.Startup %1 %2 %3 %4 %5 %6 %7 %8 %9 rem java com.sun.web.shell.Startup %1 %2 %3 %4 %5 %6 %7 %8 %9 rem clean up
-set CLASSPATH=%cp%
set port=
set host=
set test=
set jsdkJars=
set jspJars=
set beanJars=
set miscJars=
set appJars=
set appClassPath=
set cp=
rem pause 需要将其中的
set sysJars=%JAVA_HOME%\lib\tools.jar
修改为你的JDK 安装目录 如 set sysJars=c:\jdk13\lib\tools.jar 也可直接将 tools.jar 加入到 CLSSPATH 环境变量中 最后 需要修改 startserverr.bat 文件的属性 将初始环境的内存 设置为2816 以上 最好设置为 4096
需要补充说明的是 在Windows 的 Autoexec.bat 文件中 需要在设置环境变量 PATH 时 加入Java 虚拟机的路径 如
SET PATH=e:\jdk13\bin;C:\WINDOWS;C:\WINDOWS\COMMAND 修改设置后 运行startserver.bat 其结果如图 7-3 所示
图7-3 运行 JSWDK
启 动 JSWDK 后 如 果 你 没 有 修 改 服 务 器 端 口 则 可 在 浏 览 器 地 址 栏 中 输 入 http://localhost:8080/查看服务器文档 如图 7-4 所示
图7-4 JSWDK 文档 这是JSWDK 的默认文档 显示 JSWDK 的部分帮助信息 如果要终止服务器的运行 可在命令窗口中输入stopserver 命令 一般不要直接采用关闭 Windows 窗口的方法 以免 发生意想不到的错误