在WEB.XML文件中设置参数:
<?xmlversion="1.0"encoding="ISO-8859-1"?>
<!DOCTYPEweb-appPUBLIC"-//SunMicrosystems,Inc.//DTDWebApplication2.3//EN""http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<servlet>
<servlet-name>myjsp</servlet-name>
<jsp-file>/MyJsp.jsp</jsp-file>
<init-param>
<param-name>firstparam</param-name>
<param-value>firstparamvalue</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>myjsp</servlet-name>
<url-pattern>/myurl/*</url-pattern>
</servlet-mapping>
</web-app>
下面的程序无法取出在WEB.XML中定义的参数firstparam的值firstparamvalue
<html>
<HEAD><TITLE>myjsppage.jsp</TITLE></HEAD>
Myinitparameteris<%=application.getInitParameter("firstparam")%>
</html>
下面的程序就可以取出在WEB.XML中定义的参数firstparam的值firstparamvalue
<%
StringStr1;
Str1=config.getInitParameter("firstparam");
Out.println(Str1);
%>
因为config是类javax.servlet.ServletConfig的对象,而application是类javax.servlet.ServletContext的对象.
如果指定WebLogicSERVER的侦听端口为80,那么在IE中就不用输入端口
http://hostname/myfile.html取代http://hostname:portnumber/myfile.html.