JSP page forwards the request collection Jump
1, response.sendRedirect (url)
The request is redirected, the parameters of the original page is not here, that use request.getParameter ("param") returns null
2, forward the request forwarding, refer to the original page request, response objects passed a new page, so this page has the same old request, response object. This request.getParameter ("param") to the corresponding values can be
3, distinguish ServletContext.getRequestDispatcher and ServletRequest.getRequestDispatcher
ServletContext.getRequestDispatcher relative context path must be the absolute path
ServletRequest.getRequestDispatcher may be a relative can also be absolutely
4, attention is this: After using the forward forward to see in the browser address bar shows is not transmitted before forwarding the post. If the test.jsp to good.jsp forward, then the address bar shows test.jsp. This is because the forward was carried out on the server side, the browser did not know, but redirection is carried out in the client, so Use response.sentRedirect ("red.jsp") will be directly directed to red.jsp. And that brings me index.jsp servlet if the request is then carried out forawrd servlet forward to another red.jsp page, but view the results, in the address bar displays the name of the servlet that will only rather than red.jsp, if you want to know the name of the final page to see that only the search code.
reference it:
Server-side to turn the four kinds of methods:
1. ServletContext of getRequestDispatcher ()
2. ServletContext of getNamedDispatcher ()
3. ServletRequest of getRequestDispatcher ()
4. ServletResponse of sendRedirect () to turn.
1.2.3 => forward () 4. SendRedirect ()
Using the forward method because it more efficient. Only way forward can not be used (for example, to turn to a non web application), then use ServletResponse the sendRedirect () method.
Comparison with sendRedirect
Although sendRedirect methods can browse the web browser, redirect to another page, but the two are not the same in principle.
a.: Action is to use server-side, the data output to the buffer mechanism, the previous page is still output to the client before the cancellation of the output data, and then output the data to another Web page, to redirect the browser effect.
Advantages: two pages within the object request can be shared between the variables.
b. sendRedirect: action through the HTTP protocol Header, redirect the browser to issue commands, therefore, does not involve the issue to the server-side buffer.
However, as sendRedirect method acting on the client, so redirect there around the page can not share the variables in the request object.
Solution: response.sendRedirect ("sendRedirect.htm? Name = sparkwu & E-Mail = spark.wu @ cobra-tech.com")
Recommand Link:
mkv video format
Mp4 To Mp3 Converter
Recommend Converters And Optimizers
Compare Adventure And Roleplay
Hope Wii CELL Phone Deconde
My favorite Audio And Multimedia
Vacations AVI To DVD
REALPLAYER h.264
Youtube MOVIE to DAT Home
Infomation Audio Presentation Tools
Jiangmin Response To The Letter, Said Attorney Alibaba China Lagged Far Behind The Law
Converting mp3 to aac
M3U ID3 TO M3U
RER DVD To IPhone Converter
Swift DVD to Zune
Myth Of The Fastest Growing Job Market Promotion