http://localhost:8080/dispatching/MyServletz,
where dispatching is context path, MyServletz is the servlet path.
I have html/copyright.jsp in my webapp root.
My file structure is :
|--dispatching
|--WEB-INF
|--classes
|--html
| -- copyright.jsp
My servlet code is like this:
Code: Select all
@WebServlet(name = "MyServlet", urlPatterns = {"/MyServletz"})
public class MyServlet extends HttpServlet {
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
request.getRequestDispatcher("../html/copyright.jsp").include(request, response);
}
}
But I tried this:
Code: Select all
@WebServlet(name = "MyServlet", urlPatterns = {"/MyServletz"})
public class MyServlet extends HttpServlet {
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
request.getRequestDispatcher("html/copyright.jsp").include(request, response);
}
}