简体   繁体   English

JSP中的Servlet

[英]Servlet inside a JSP

I have a Servlet inside a JSP that display an image 我在JSP中有一个显示图像的Servlet。

<img id='225926' 
       src='http://127.0.0.1:7001/mindfulness/displayLogo?  
          resize=true&height=100' align='bottom' />

The servlet: Servlet:

public void doGet(HttpServletRequest request, HttpServletResponse response) 
                        throws IOException, ServletException {

            System.out.println  ("DisplayImageServlet : "); 
            ...
}

But it seems that when I push the back button in the browser, the servlet is not called again and I see the previous image 但是,当我按浏览器中的后退按钮时,似乎没有再次调用该servlet,并且看到了上一张图像

That sounds like a browser cache issue. 这听起来像是浏览器缓存问题。 One common solution to this would be to generate a random number and append it as a request parameter to the servlet URL. 一种常见的解决方案是生成一个随机数,并将其作为请求参数附加到Servlet URL。 The servlet can ignore the paramter, but this should make the URL unique and therefore uncacheable servlet可以忽略该参数,但这将使URL唯一,因此不可缓存

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM