Javatpoint Logo

Unable to get the Servlet name.

By: ankitk*** On: Tue Feb 28 21:02:26 IST 2017     Question Reputation0 Answer Reputation0 Quiz Belt Series Points0  0Blank User
My web.xml file is:

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.1" 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_3_1.xsd">

<servlet>
<servlet-name>ConfigExample</servlet-name>
<jsp-file>/configExample.jsp</jsp-file>
</servlet>
<servlet-mapping>
<servlet-name>ConfigExample</servlet-name>
<url-pattern>/configExample</url-pattern>
</servlet-mapping>


<session-config>
<session-timeout>
30
</session-timeout>
</session-config>
<welcome-file-list>
<welcome-file> index.html </welcome-file>
</welcome-file-list>
</web-app>


ConfigExample.jsp File is:

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Config Implicit Object</title>
</head>
<body>
<%
String sname = config.getServletName();
out.print("Servlet Name is: " + sname);
%>
</body>
</html>

Output on browser :

Servlet Name is: jsp
Up0Down