0

I have some java code in a servlet which I want the user to re-directed to an HTML file via a link:

/**
 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
 */
     protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

     //...

     StringBuffer sb = new StringBuffer();
     sb.append("<a href=\"login.html\">Login</a>")

     //...
    }

Given that this is syntatically correct, the servlet will produce a link. The link shows me ERROR 404: Project/login.html

The url-mapping in the web.xml for Project uses /login for the LoginServlet. But I dont want to be directed to the LoginServlet. I neeed to be directed to the login.html that is in my WEB-INF under WebContent project directory.

cryptomath
  • 141
  • 9

1 Answers1

1

Every file under WEB-INF, by design, is not accessible from the outside. That's where you store stuff (like your classes) that you do not want to expose on the web.

Your login.html file should be at the root of the war file, next to the WEB-INF directory, and not inside.

JB Nizet
  • 678,734
  • 91
  • 1,224
  • 1,255