通过servlet更新当前的jsp页面? [英] Update current jsp page through servlet?

查看:113
本文介绍了通过servlet更新当前的jsp页面?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

作为大学网络项目的一部分,我将编写一个网络商店代码.

As a part of a web project in college, I'm going to code a webshop.

我有一个Java Servlet,在其中将项目添加到购物篮中.可以从列出了项目的其他JSP站点调用此servlet.我无法弄清楚的是如何刷新页面.

I have a Java servlet where I add items to a basket. This servlet can be called from different JSP sites where i have items listed. What i cant figure out is how to refresh the page.

我一直在搜寻,发现了两个建议;

I have been googling around, and found 2 proposals;

response.setHeader("Refresh", "1");

response.sendRedirect("/demo.jsp")

我不能真正使用解决方案2,因为我不知道必须重定向到哪个项目,就像它从多个JSP站点调用的那样,我只想停留在同一页面上.

I can't really use solution 2, because I dont know what item I have to redirect to, as it called from several JSP sites, and I just want to stay on the same page.

根据我对解决方案1的了解,这不仅是一次刷新,而是一个脚本,该脚本以一秒钟的间隔不断更新网站.

And from what I understand from solution 1, that isn't just a 1 time refresh, but a script that keep updating the site with one-second intervals.

那么任何人都可以帮助我:将商品添加到购物篮后,如何仅刷新一次网站?

So can anyone help me: How can I refresh the site just once, when an item is added to my basket?

推荐答案

如果您只想刷新页面,则可以调用reload函数

If you just want to refresh the page you can call reload function

示例

<input type="button" value="Reload Page" onClick="document.location.reload(true)"> 

代码由 http://www.quackit.com/javascript/javascript_refresh_page.cfm

这篇关于通过servlet更新当前的jsp页面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆