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.

1
  • My login.html does not have a little arrow pointing north west Commented Oct 12, 2014 at 20:21

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

1 Comment

It was where the login.html was placed. Indeed, thanks for your response.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.