dateIPServlet.java
Other gets
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;
import java.text.DateFormat;
public class dateIPServlet extends HttpServlet {
protected void doGet(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException
{
String ip = req.getRemoteAddr();
req.setAttribute("theip", ip);
String pt = Integer.toString(req.getLocalPort());
req.setAttribute("theport", pt);
String rpt = Integer.toString(req.getRemotePort());
req.setAttribute("therport", rpt);
String cp=req.getContextPath();
req.setAttribute("thecp", cp);
String url=req.getRequestURL().toString();
req.setAttribute("theurl", url);
String qs=req.getQueryString();
req.setAttribute("theqs", qs);
DateFormat df=DateFormat.getDateTimeInstance(DateFormat.LONG,DateFormat.LONG);
String thedate=df.format(new Date());
req.setAttribute("thedate", thedate);
RequestDispatcher rd = req.getRequestDispatcher("showDateIP.jsp");
rd.forward(req, res);
}
}