Set parameters in the web. xml file:
<? XML version = "1.0" encoding = "ISO-8859-1"?>
<! Doctype web-app public "-// Sun Microsystems, Inc. // DTD web application 2.3 //" 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>
The followingProgramThe firstparam value of the parameter defined in Web. xml cannot be retrieved.
<HTML>
<Head> <title> my JSP page. jsp </title> My init parameter is <% = application. getinitparameter ("firstparam") %>
</Html>
The following program can retrieve the firstparamvalue of the firstparam parameter defined in Web. xml.
<%
String str1;
Str1 = config. getinitparameter ("firstparam ");
Out. println (str1 );
%>
Because config is an object like javax. servlet. servletconfig, and application is an object like javax. servlet. servletcontext.
If the listening port of Weblogic server is set to 80, you do not need to enter the port in IE.
Http: // hostname/myfile.html replaces http: // hostname: portnumber/myfile.html.