Advertisement
Methods | Description |
---|---|
String getInitParameter(String name) | This method gets an object stored in a session with a name, or null. |
Enumeration getInitParameterNames() | This method sets an object with a name in a session. |
ServletContext getServletContext() | This method removes an object with a name from the session. |
String getServletName() | This method returns a RequestDispatcher which acts as a wrapper for the resource at the path. |
Advertisement
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"
version="4.0"
metadata-complete="true">
<display-name>Welcome tomcat</display-name>
<description>
Welcome tomcat
</description>
<servlet>
<servlet-name>MyJspPage</servlet-name>
<jsp-file>/JspConfig.jsp</jsp-file>
<init-param>
<param-name>Name</param-name>
<param-value>DecodeJava</param-value>
</init-param>
<init-param>
<param-name>Year</param-name>
<param-value>2018</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>MyJspPage</servlet-name>
<url-pattern>/JspConfig.jsp</url-pattern>
</servlet-mapping>
</web-app>
<html>
<head>
<title>Using JSP config object</title>
</head>
<body>
<%
String sname = config.getServletName();
out.println("Servlet Name is "+ sname);
%>
<br/>
<%
out.println("Name variable retreived using config object : " + config.getInitParameter("Name"));
out.println("<br/>");
out.println("Count variable retreived using config object : " + config.getInitParameter("Count"));
%>
</body>
</html>
Advertisement
Advertisement
Please check our latest addition
C#, PYTHON and DJANGO
Advertisement