Reputation: 3
I have a html file addemployee.html which i need to call from a servlet.
I have tried following statements .. but neither are working:
out.print("<a href='/addemployee.html'>1.Add New Employee</a>");
out.print("<a href=/"addemployee.html/">1.Add New Employee</"a>");
Always getting error 404.The html file is stored in the same package as the servlet.
Can anyone please tell what the problem could be. Any help would be highly appreciated.
Upvotes: 0
Views: 8598
Reputation: 18020
You are missing context root. You can use any of the following:
out.print("<a href='addemployee.html'>1.Add New Employee</a>"); // relative if on same level as servlet
out.print("<a href='/WebApplication1/addemployee.html'>1.Add New Employee</a>"); // absolute - hardcoded context
out.print("<a href='" + getServletContext().getContextPath() + "/addemployee.html'>1.Add New Employee</a>"); // absolute - context read from configuration
Upvotes: 3