config.getInitParameter

web.xml
 <servlet>
  	<servlet-name>servlet1</servlet-name>
  	<jsp-file>/index.jsp</jsp-file>
  	<init-param>
  		<param-name>str</param-name>
  		<param-value>helloworld!</param-value>
  	</init-param>
  </servlet>
  <servlet-mapping>
  	<servlet-name>servlet1</servlet-name>
  	<url-pattern>/servlet1</url-pattern>
  </servlet-mapping>

jsp
 <%=config.getInitParameter("str") %>
 <%=config.getServletName() %>


你可能感兴趣的