0

I added a servlet to my web app and a servlet mapping but now nothing but a blank screen when I go to my web page, and no errors in the developer console. Can anyone help?

<?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_2_5.xsd" id="WebApp_ID" version="2.5">
  <display-name>BasicJavaWeb</display-name>
  <welcome-file-list>
    <welcome-file>index.html</welcome-file>
    <welcome-file>index.htm</welcome-file>
    <welcome-file>index.jsp</welcome-file>
    <welcome-file>default.html</welcome-file>
    <welcome-file>default.htm</welcome-file>
    <welcome-file>default.jsp</welcome-file>
  </welcome-file-list>
  <servlet>
    <display-name>AuthenticatorServlet</display-name>
    <servlet-name>AuthenticatorServlet</servlet-name>
    <servlet-class>AuthenticatorServlet</servlet-class>
  </servlet>
  <servlet-mapping>
    <servlet-name>AuthenticatorServlet</servlet-name>
    <url-pattern>authenticator</url-pattern>
    <url-pattern>authenticator</url-pattern>
  </servlet-mapping>
</web-app>

Before I added servlet/servlet-mappings, this web.xml file did display index.html:

<?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_2_5.xsd" id="WebApp_ID" version="2.5">
  <display-name>BasicJavaWeb</display-name>
  <welcome-file-list>
    <welcome-file>index.html</welcome-file>
    <welcome-file>index.htm</welcome-file>
    <welcome-file>index.jsp</welcome-file>
    <welcome-file>default.html</welcome-file>
    <welcome-file>default.htm</welcome-file>
    <welcome-file>default.jsp</welcome-file>
  </welcome-file-list>
</web-app>

So what would the problem be by just adding servlets?

Tanvi
  • 1
  • 1
    Check your console. You probably have an error. And the error is probably caused by the fact that your servlet class is in the default package. Never, ever, ever put any class in the default package. – JB Nizet Nov 06 '16 at 22:12
  • Thanks! I did check the console and didn't see any errors - but I was using the default package and moved it to a new package. It's still not working though. – Tanvi Nov 07 '16 at 01:55

1 Answers1

0

In the servlet mapping you have

<url-pattern>authenticator</url-pattern>
<url-pattern>authenticator</url-pattern>

I don't understand why you declare it twice, but anyway the tag value should begin in a "/" like

<url-pattern>/authenticator</url-pattern>
<url-pattern>/authenticator</url-pattern>
lonchu
  • 21
  • 6