Name | Interface | Tomcat Implementation |
---|---|---|
config | javax.servlet.ServletConfig | org.apache.catalina.core.StandardWrapperFacade |
How to access servlet config parameters in jsp?
Servlet config init parameter : <%=config.getInitParameter("servletConfigParm1")%>
JSP Implicit Object config Example (github)
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>ourownjava.com</title> </head> <body> <!-- jsp implicit object config example --> JSP implicit object config class : <%=config.getClass().getCanonicalName() %> <p/> <!-- the above line will return org.apache.catalina.core.StandardWrapperFacade, its an implementation of javax.servlet.ServletConfig --> <!-- access the servlet config parameter from the web.xml --> Servlet config init parameter : <%=config.getInitParameter("servletConfigParm1")%> </body> </html>
Servlet Context Parameters in web.xml (github)
<?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0"> <display-name>jsp.ourownjava.com</display-name> <welcome-file-list> <welcome-file>index.jsp</welcome-file> </welcome-file-list> <!-- servlet init parameter, for this particular servlet, jsp implicit object 'config' would make available these parameters, class is javax.servlet.ServletConfig --> <servlet> <servlet-name>jspImplicitObjectConfigExample</servlet-name> <jsp-file>/jsp-implicit-object-config-example.jsp</jsp-file> <init-param> <param-name>servletConfigParm1</param-name> <param-value>servletConfigParam1Value</param-value> </init-param> </servlet> <servlet-mapping> <servlet-name>jspImplicitObjectConfigExample</servlet-name> <url-pattern>/jsp-implicit-object-config-example.jsp</url-pattern> </servlet-mapping> </web-app>
How to run the example program?
Lion s Mane Gummies for brain and memory. Lion Mane www.au.lionsmanegummiesfn.com.