J
Joel S
I wrote a servlet that appears to have a cache issue, everytime i hit
reload it appends to the data in the browser already. I've tried
everything i can think of to fix this issue but would appreacite any
advice you may have.
the code is below:
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
* Servlet implementation class for Servlet: index
*
*/
public class index extends javax.servlet.http.HttpServlet implements
javax.servlet.Servlet {
/* (non-Java-doc)
* @see javax.servlet.http.HttpServlet#HttpServlet()
*/
public index() {
super();
}
/* (non-Java-doc)
* @see javax.servlet.http.HttpServlet#doGet(HttpServletRequest
request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse
response) throws ServletException, IOException {
// TODO Auto-generated method stub
response.setContentType("text/html");
response.setHeader("Cache-Control", "no-cache");
response.setHeader("Expires", "Sun, 15 Jan 1998 17:00:00 GMT");
response.setHeader("Pragma", "no-cache");
response.setDateHeader("Max-Age", 0);
PrintWriter out = response.getWriter();
StringBuffer buffer = new StringBuffer( 1024 );
buffer.append("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0
Strict//EN\">\n");
try
{
buffer.append(this.generatePage());
out.print(buffer.toString());
out.close();
response.flushBuffer();
}
catch (Exception e)
{
e.printStackTrace(out);
}
}
/* (non-Java-doc)
* @see javax.servlet.http.HttpServlet#doPost(HttpServletRequest
request, HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse
response) throws ServletException, IOException {
// TODO Auto-generated method stub
}
private String generatePage() throws Exception {
ServletContext sc = getServletContext();
Jtpl tpl = new Jtpl(sc.getRealPath("/") + "Template.jtpl");
tpl.assign("TITLE", "Rippr");
tpl.parse("head");
tpl.assign("COMMENT", "<!-- piece of junk -->");
tpl.parse("main");
return tpl.out();
}
}
reload it appends to the data in the browser already. I've tried
everything i can think of to fix this issue but would appreacite any
advice you may have.
the code is below:
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
* Servlet implementation class for Servlet: index
*
*/
public class index extends javax.servlet.http.HttpServlet implements
javax.servlet.Servlet {
/* (non-Java-doc)
* @see javax.servlet.http.HttpServlet#HttpServlet()
*/
public index() {
super();
}
/* (non-Java-doc)
* @see javax.servlet.http.HttpServlet#doGet(HttpServletRequest
request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse
response) throws ServletException, IOException {
// TODO Auto-generated method stub
response.setContentType("text/html");
response.setHeader("Cache-Control", "no-cache");
response.setHeader("Expires", "Sun, 15 Jan 1998 17:00:00 GMT");
response.setHeader("Pragma", "no-cache");
response.setDateHeader("Max-Age", 0);
PrintWriter out = response.getWriter();
StringBuffer buffer = new StringBuffer( 1024 );
buffer.append("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0
Strict//EN\">\n");
try
{
buffer.append(this.generatePage());
out.print(buffer.toString());
out.close();
response.flushBuffer();
}
catch (Exception e)
{
e.printStackTrace(out);
}
}
/* (non-Java-doc)
* @see javax.servlet.http.HttpServlet#doPost(HttpServletRequest
request, HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse
response) throws ServletException, IOException {
// TODO Auto-generated method stub
}
private String generatePage() throws Exception {
ServletContext sc = getServletContext();
Jtpl tpl = new Jtpl(sc.getRealPath("/") + "Template.jtpl");
tpl.assign("TITLE", "Rippr");
tpl.parse("head");
tpl.assign("COMMENT", "<!-- piece of junk -->");
tpl.parse("main");
return tpl.out();
}
}