About Question enthuware.jwpv6.2.1090 :
Posted: Sat Jun 04, 2016 8:09 pm
Hi, suppose my servlet can be access through this URL:
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:
It returns a null pointer exception as ../html/copyright.jsp is not found.
But I tried this:
It works and includes the copyright.jsp content.
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);
}
}