InfoCenter Home > 3.3.2.1: Example: Migrating HttpServiceResponse.callPage()Calls to HttpServiceResponse.callPage() need to be replaced by calls to RequestDispatcher, as shown. Before -- Using HttpServiceResponse.callPage()import java.io.*; import javax.servlet.*; import javax.servlet.http.*; public class UpdateJSPTest extends HttpServlet { public void doGet (HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { String message = "This is a test"; ((com.sun.server.http.HttpServiceRequest)req).setAttribute("message", message); ((com.sun.server.http.HttpServiceResponse)res).callPage("/Update.jsp", req); } } After -- Using RequestDispatcherimport java.io.*; import javax.servlet.*; import javax.servlet.http.*; public class UpdateJSPTest extends HttpServlet { public void doGet (HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { String message = "This is a test"; req.setAttribute("message", message); RequestDispatcher rd = getServletContext().getRequestDispatcher("/Update.jsp"); rd.forward(req, res); //((com.sun.server.http.HttpServiceRequest)req).setAttribute("message", message); //((com.sun.server.http.HttpServiceResponse)res).callPage("/Update.jsp", req); } }
|
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|