Sending redirect to another servlet/JSP without loosing the request parameters
2015-09-22 11:43
711 查看
How do i specify a redirection to another servlet, in the
at the moment I’m using
which is wrong since, my parameters in the doGet() method of
So I’m left with an empty products page after logging in :/
You need to use
This way the webbrowser will be instructed to fire a new HTTP GET request on the given URL and thus the
doPost()method of a servlet.
at the moment I’m using
request.getRequestDispatcher("/WEB-INF/products.jsp").forward(request, response);
which is wrong since, my parameters in the doGet() method of
productsare not being called and initialized.
So I’m left with an empty products page after logging in :/
You need to use
HttpServletResponse#sendRedirect()to send a redirect. Assuming that the servlet is mapped on an URL pattern of
/products:
response.sendRedirect("/products");
This way the webbrowser will be instructed to fire a new HTTP GET request on the given URL and thus the
doGet()method of the servlet instance will be called where you can in turn load the products and forward to a JSP which displays them the usual way.
相关文章推荐
- Servlet与JSP间的两种传值情况
- JSP、Servlet中get请求和post请求的区别总结
- jsp和servlet的区别探讨
- asp.net中Response.Redirect与Server.Transfer的区别分析
- Struts2访问servlet分享
- java中Servlet处理乱码的方法
- iis下设置301 Redirect 永久重定向的方法
- Servlet 过滤器详细介绍
- servlet中session简介和使用例子
- 在Jsp Servlet中页面重新定向总汇
- Servlet动态网页技术详解
- jsp和servlet操作mysql中文乱码问题的解决办法
- 基于jsp+servlet实现的简单博客系统实例(附源码)
- js调用后台servlet方法实例
- 关于shopex同步ucenter的redirect问题,导致script不运行
- 三种方法让Response.Redirect在新窗口打开
- 利用JQuery和Servlet实现跨域提交请求示例分享
- JavaWeb编程 Servlet的基本配置
- java servlet 几种页面跳转的方法