import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
public class counter extends HttpServlet
{
@Override
public void doGet(HttpServletRequest req,HttpServletResponse res) throws IOException
{
HttpSession session=req.getSession(true);
Integer count=(Integer)session.getAttribute("count");
if(count==null)
{
count=1;
}
else
{
count=new Integer(count.intValue()+1);
}
session.setAttribute("count", count);
PrintWriter pw=res.getWriter();
pw.println("counter is="+count);
}
}
A blog provide anexample with sample code for swing , servlet, jdbc and odbc connection to database, jsp, servlets, taglib, sql server, cassandra and many more. we also provide Apache camel sample code for integration.
Tuesday, October 16, 2012
statefull visitor counter
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment