Filename-trackUser.jsp
<html>
<body>
<h2> User First page </h2>
<%
Integer
mycount=(Integer)session.getAttribute("accesscount");
if(mycount==null)
{
mycount=0;
}
session.setAttribute("accesscount",++mycount);
%>
<br>
Accesscount=<%= mycount %>
<%
String
rurl=request.getRequestURI();
String
surl=(String)session.getAttribute("url");
session.setAttribute("url",
rurl+ " " +surl);
%>
</body>
</html>
Filename-trackUser2.jsp
<html>
<body>
<h2> User Second page
</h2>
<%
Integer
mycount=(Integer)session.getAttribute("accesscount");
if(mycount==null)
{
mycount=0;
}
session.setAttribute("accesscount",++mycount);
%>
<br>
Accesscount=<%= mycount %>
<%
String
rurl=request.getRequestURI();
String
surl=(String)session.getAttribute("url");
session.setAttribute("url",
rurl+ " " +surl);
%>
</body>
</html>
Filename-TrackUser.java
package def25;
import java.io.*;
import java.util.*;
import javax.servlet.http.*;
import javax.servlet.*;
import java.util.Date.*;
public class TrackUser extends
HttpServlet
{
public
void doGet(HttpServletRequest req, HttpServletResponse res) throws
IOException,ServletException
{
res.setContentType("Text/html");
PrintWriter
out=res.getWriter();
out.println("TrackUser
is call");
HttpSession
session=req.getSession();
Integer
mycount=(Integer)session.getAttribute("accesscount");
if(mycount==null)
{
mycount=0;
}
String
surl=(String)session.getAttribute("url");
if(surl==null)
{
surl="
";
}
out.println("<br>
access pages:"+surl);
out.println("<br>
User have requeste="+mycount);
}
}
Output
No comments:
Post a Comment