0

I am developing a spring mvc application on tomcat. the problem is that tomcat is refreshing pages each 2/3minutes, i can't see why ! my config is

web.xml

<?xml version="1.0" encoding="UTF-8"?>

http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">

<context-param>
    <param-name>javax.servlet.jsp.jstl.fmt.localizationContext</param-name>
    <param-value>messages</param-value>
</context-param>
<context-param>
    <param-name>javax.servlet.jsp.jstl.fmt.fallbackLocale</param-name>
    <param-value>fr</param-value>
</context-param>
<context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>classpath:portal.xml</param-value>
</context-param>

<listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

<servlet>
    <servlet-name>portal</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <init-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>
            <!--
                desactivation du context : utilisation du context parent
            -->
        </param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
    <servlet-name>portal</servlet-name>
    <url-pattern>*.htm</url-pattern>
</servlet-mapping>
<servlet-mapping>
    <servlet-name>portal</servlet-name>
    <url-pattern>/index.htm</url-pattern>
</servlet-mapping>  
<servlet-mapping>
    <servlet-name>portal</servlet-name>
    <url-pattern>*.ajax</url-pattern>
</servlet-mapping>

<filter>
    <filter-name>encodingFilter</filter-name>
    <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
    <init-param>
        <param-name>encoding</param-name>
        <param-value>UTF-8</param-value>
    </init-param>
    <init-param>
        <param-name>forceEncoding</param-name>
        <param-value>true</param-value>
    </init-param>
</filter>
<filter-mapping>
    <filter-name>encodingFilter</filter-name>
    <url-pattern>/*</url-pattern>
    <dispatcher>REQUEST</dispatcher>
    <dispatcher>FORWARD</dispatcher>
</filter-mapping>

<filter>
    <filter-name>springSecurityFilterChain</filter-name>
    <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>
<filter-mapping>
    <filter-name>springSecurityFilterChain</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>

<session-config>
    <session-timeout>30</session-timeout>
</session-config>
<welcome-file-list>
    <welcome-file>index.htm</welcome-file>
</welcome-file-list>
<jsp-config>
    <jsp-property-group>
        <url-pattern>*.jsp</url-pattern>
        <el-ignored>false</el-ignored>
        <page-encoding>UTF-8</page-encoding>
        <scripting-invalid>false</scripting-invalid>
    </jsp-property-group>
</jsp-config>

server.xml

      <Host name="localhost"  appBase="webapps"
        unpackWARs="true" autoDeploy="true"
        xmlValidation="false" xmlNamespaceAware="false">

    <!-- SingleSignOn valve, share authentication between web applications
         Documentation at: /docs/config/valve.html -->
    <!--
    <Valve className="org.apache.catalina.authenticator.SingleSignOn" />
    -->

    <!-- Access log processes all example.
         Documentation at: /docs/config/valve.html -->
    <!--
    <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"  
           prefix="localhost_access_log." suffix=".txt" pattern="common" resolveHosts="false"/>
    -->
    <!--
   <Context docBase="/home/badrux/Work/apache-tomcat-6.0.26/webapps/portal" path="/" reloadable="true"></Context>
    -->
   <Context path="/images" docBase="/root/collecte/images" reloadable="false"/>
   <Context path="/statics" docBase="/root/collecte/statics" reloadable="false"/>
   <Context path="/sitemap" docBase="/root/collecte/sitemap" reloadable="false"/>
  </Host>

thanks in advance

2

2 Answers 2

3

Server cannot refresh page by itself, there is no simple way of achieving that. If you really experiencing such behavior, then somewhere in your code you have an explicit refresh (redirect perhaps? JavaScript maybe?) or AJAX is forcing page reload.

Please note that I said "simple way". You could do that by more sophisticated technologies, but it is highly unlikely that you are doing that.

5
  • i will check all my scripts ! Jan 27, 2012 at 15:37
  • I disabled all page scripts, but still have refreshing behavior, I think this a tomcat config problem. If u want I can attach my jsp+layout pages code Jan 27, 2012 at 17:24
  • That could help, please do so. Jan 27, 2012 at 21:15
  • I don't understand ur response? Jan 27, 2012 at 23:36
  • I meant, that posting here your JSP and JavaScript can help us with solving this puzzle. Jan 28, 2012 at 10:55
2

You have a:

<meta http-equiv="refresh" content="240" />

in the page header, which means you are telling the browser to refresh the page every 4 minutes (240 seconds).

As an additional observation, you're also creating a session when rendering the home page, which is probably an unnecessary overhead.

3
  • u are right, thanks Luke, the problem was <meta http-equiv="refresh" content="240" />. What do you mean by "you're also creating a session when rendering the home page" ? Jan 28, 2012 at 21:32
  • @MokhlisseBadre, please reward Luke with accepting his answer :) Jan 29, 2012 at 14:37
  • @Mokhlisse I mean there is a session created on the server when you browse to the main page - I can see the JSESSIONID being set. If there is no good reason for this then you should avoid the waste of server-side resources. Note that unless you use <%@ page session="false" %> in a JSP it will create a session if one doesn't already exist. Jan 29, 2012 at 18:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.