archrajan
asked on
BROWSER BACK
Hi i wud like to know a way by which i cud
reload the page fresh from the server eachtime the user clicks the browser 's back button..
i cannot have links to go back...
i want it with the browsers back button...
right now whenever i click back the page reloads from cache... and its not going to the server again..
any help is deeply appreciated
reload the page fresh from the server eachtime the user clicks the browser 's back button..
i cannot have links to go back...
i want it with the browsers back button...
right now whenever i click back the page reloads from cache... and its not going to the server again..
any help is deeply appreciated
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
it doesnt work for me...
i put those lines in the head of my page
i put those lines in the head of my page
Try adding a dummy variable with your URL..
something like http://localhost:8080/mypage.jsp?dummy=dummy.
As I said back button is a browser function and browser itslef handles it.. All we can try is to tell browser not pick it up from cache ( thats what we tried to do by putting those lines in the response..) it should have worked.
One more thing that you should do is to go to tools-->internet options-->settings
and select the radio button which says 'every visit to the page'.
These settings should work
something like http://localhost:8080/mypage.jsp?dummy=dummy.
As I said back button is a browser function and browser itslef handles it.. All we can try is to tell browser not pick it up from cache ( thats what we tried to do by putting those lines in the response..) it should have worked.
One more thing that you should do is to go to tools-->internet options-->settings
and select the radio button which says 'every visit to the page'.
These settings should work
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
TimYates do i add it in the head section? in both the jsp files...
Yeah, that should do!
Personally, I have an HttpFilter which adds it to the response for every request to my webapp...
But adding it to the top (before <HTML>) should do it :-)
Personally, I have an HttpFilter which adds it to the response for every request to my webapp...
But adding it to the top (before <HTML>) should do it :-)
>> TimYates do i add it in the head section?
Add it before all the rest of the page;
----
<%
// Set to expire far in the past.
response.setHeader("Expire s", "Sat, 6 May 1995 12:00:00 GMT");
// Set standard HTTP/1.1 no-cache headers.
response.setHeader("Cache- Control", "no-store, no-cache, must-revalidate");
// Set IE extended HTTP/1.1 no-cache headers (use addHeader).
response.addHeader("Cache- Control", "post-check=0, pre-check=0");
// Set standard HTTP/1.0 no-cache header.
response.setHeader("Pragma ", "no-cache");
%>
<HTML>
<HEAD>
<TITLE>Woo!</TITLE>
etc...
Add it before all the rest of the page;
----
<%
// Set to expire far in the past.
response.setHeader("Expire
// Set standard HTTP/1.1 no-cache headers.
response.setHeader("Cache-
// Set IE extended HTTP/1.1 no-cache headers (use addHeader).
response.addHeader("Cache-
// Set standard HTTP/1.0 no-cache header.
response.setHeader("Pragma
%>
<HTML>
<HEAD>
<TITLE>Woo!</TITLE>
etc...
Normally I put them in a filter and applies it to all the pages... Works for me!!
package org.whatever ;
import javax.servlet.Filter ;
import javax.servlet.FilterChain ;
import javax.servlet.FilterConfig ;
import javax.servlet.ServletExcep tion ;
import javax.servlet.ServletReque st ;
import javax.servlet.ServletRespo nse ;
import javax.servlet.http.HttpSer vletReques t ;
import javax.servlet.http.HttpSer vletRespon se ;
import org.apache.commons.logging .Log ;
import org.apache.commons.logging .LogFactor y ;
public class RequestFilter implements Filter
{
private static Log log = LogFactory.getLog( RequestFilter.class ) ;
private FilterConfig filterConfig;
public void doFilter( final ServletRequest req, final ServletResponse res, FilterChain chain ) throws IOException, ServletException
{
HttpServletRequest response = (HttpServletResponse)res ;
// Set to expire far in the past.
response.setHeader("Expire s", "Sat, 6 May 1995 12:00:00 GMT");
// Set standard HTTP/1.1 no-cache headers.
response.setHeader("Cache- Control", "no-store, no-cache, must-revalidate");
// Set IE extended HTTP/1.1 no-cache headers (use addHeader).
response.addHeader("Cache- Control", "post-check=0, pre-check=0");
// Set standard HTTP/1.0 no-cache header.
response.setHeader("Pragma ", "no-cache");
chain.doFilter( request, response ) ;
}
public void setFilterConfig( final FilterConfig filterConfig )
{
this.filterConfig = filterConfig ;
}
public void init( FilterConfig config )
{
this.filterConfig = config ;
}
public void destroy()
{
this.filterConfig = null ;
}
}
Then, in web.xml:
<filter>
<filter-name>requestfilter </filter-n ame>
<filter-class>org.whatever .RequestFi lter</filt er-class>
</filter>
<filter-mapping>
<filter-name>requestfilter </filter-n ame>
<url-pattern>*.jsp</url-pa ttern>
</filter-mapping>
import javax.servlet.Filter ;
import javax.servlet.FilterChain ;
import javax.servlet.FilterConfig
import javax.servlet.ServletExcep
import javax.servlet.ServletReque
import javax.servlet.ServletRespo
import javax.servlet.http.HttpSer
import javax.servlet.http.HttpSer
import org.apache.commons.logging
import org.apache.commons.logging
public class RequestFilter implements Filter
{
private static Log log = LogFactory.getLog( RequestFilter.class ) ;
private FilterConfig filterConfig;
public void doFilter( final ServletRequest req, final ServletResponse res, FilterChain chain ) throws IOException, ServletException
{
HttpServletRequest response = (HttpServletResponse)res ;
// Set to expire far in the past.
response.setHeader("Expire
// Set standard HTTP/1.1 no-cache headers.
response.setHeader("Cache-
// Set IE extended HTTP/1.1 no-cache headers (use addHeader).
response.addHeader("Cache-
// Set standard HTTP/1.0 no-cache header.
response.setHeader("Pragma
chain.doFilter( request, response ) ;
}
public void setFilterConfig( final FilterConfig filterConfig )
{
this.filterConfig = filterConfig ;
}
public void init( FilterConfig config )
{
this.filterConfig = config ;
}
public void destroy()
{
this.filterConfig = null ;
}
}
Then, in web.xml:
<filter>
<filter-name>requestfilter
<filter-class>org.whatever
</filter>
<filter-mapping>
<filter-name>requestfilter
<url-pattern>*.jsp</url-pa
</filter-mapping>
<head>
<meta http-equiv="Expires" CONTENT="0">
<meta http-equiv="Cache-Control"
<meta http-equiv="Pragma" CONTENT="no-cache">
</head>