This week's book giveaway is in the OCAJP 8 forum.
We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line!
See this thread for details.
The moose likes Servlets and the fly likes cannot use the gotopage method Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "cannot use the gotopage method " Watch "cannot use the gotopage method " New topic
Author

cannot use the gotopage method

Jo Lee
Ranch Hand

Joined: Jun 26, 2001
Posts: 35
I have tried the servlet gotopage method by Maha, here is the method;
ServletUtilities.gotoPage("/Accounts/list_deputations.jsp",getServletContext(),request,response);public static void gotoPage(String address,ServletContext context,HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException {RequestDispatcher dispatcher = context.getRequestDispatcher(response.encodeURL(address));System.out.println("Dispatch forward to ="+address);dispatcher.forward(request,response);}
I get the following error
java.lang.NullPointerException
at javax.servlet.GenericServlet.getServletContext(GenericServlet.java:205)
at ServletUtilities.gotoPage(ServletUtility.java:81)
the same redirection request works with response.sendRedirect("/Accounts/list_deputations.jsp");
I double checked my tomcat4.0.4 setup with this url:http://www.moreservlets.com/Using-Tomcat-4.html#Servlet-Reloading
Why? and how to solve it?
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: cannot use the gotopage method
 
It's not a secret anymore!