發表文章

目前顯示的是 8月, 2012的文章

difference between request.getRequestDispatcher() and response.sendRedirect()

Forward( ) : javax.Servlet.RequestDispatcher interface. - RequestDispatcher.forward( ) works on the Server. - The forward( ) works inside the WebContainer. - The forward( ) restricts you to redirect only to a resource in the same web-Application. - After executing the forward( ), the control will return back to the same method from where the forward method was called. - The forward( ) will redirect in the application server itself, it does'n come back to the client. - The forward( ) is faster than Sendredirect( ) . To use the forward( ) of the requestDispatcher interface, the first thing to do is to obtain RequestDispatcher Object. The Servlet technology provides in three ways. 1. By using the getRequestDispatcher( ) of the javax.Servlet.ServletContext interface , passing a String containing the path of the other resources, path is relative to the root of the ServletContext. RequestDispatcher rd=request.getRequestDispatcher ("secondServlet"); Rd.forward(reque