1

Servlet has this annotation:

@WebServlet(name = "Download", urlPatterns = {"/download"})
public class Download extends HttpServlet {
....

And its working like expected. But I want to set this servlet as main web page. So I defined in web.xml file:

<welcome-file-list>
    <welcome-file>Download</welcome-file>
</welcome-file-list>

And it does not work, page not found. So the solution I found is:

    <servlet>
        <servlet-name>Download</servlet-name>
        <servlet-class>com.xsistema.........Download</servlet-class>
    </servlet>
    <servlet-mapping>
        <servlet-name>Download</servlet-name>
        <url-pattern>/Download</url-pattern>
    </servlet-mapping>

    <welcome-file-list>
        <welcome-file>Download</welcome-file>
    </welcome-file-list>

And now the page is found. But why its not enough only annotations without mapping it at web.xml file?

Ernestas Gruodis
  • 8,567
  • 14
  • 55
  • 117

1 Answers1

2

Try changing

@WebServlet(name = "Download", urlPatterns = {"/download"})

to

@WebServlet(name = "Download", urlPatterns = {"/download", ""})

Refer this.