Hi, gang
I have a servlet that refreshes at user defined rate and displays a bunch of different things on the page.
I would like to the user to be able to click on a link that would take him to (for instance) a middle of the page, and when the servlet refreshes again the user will still be in the same area, and not at the top of the page.
I am using meta-refresh to refresh the servlet, and I know I have to use the "A HREF" and "A NAME" commands, but I am unable to do it dynamically.
The simplified segments of my code look like this.
protected void service(HttpServletRequest request, HttpServletResponse response)
throws ServletException, java.io.IOException {
response.setContentType("text/html");
java.io.PrintWriter out = response.getWriter();
int time = (new Integer(request.getParameter(REFRESH_RATE))).intValue();
out.println("<html><head>");
out.println("<meta http-equiv='refresh' content='"+time+";URL=MyServlet?"+REFRESH_RATE+"="+time+"' frame='self'>");
out.println("</head><body>");
out.println("<A HREF='#MIDDLE'>Jump to Middle</a>");
out.println("<A NAME=TOP>");
out.println("<FORM NAME=setTime METHOD=GET ACTION="MyServlet?"+REFRESH_RATE+"="+time+"'>");
out.println("<input type=textfield name='"+REFRESH_RATE+"' value='"+time+"'>");
out.println("<input type=submit value='Refresh after this many seconds'>");
out.println("</form>");
out.println("<P>Blah blah blah<P>");
out.println("
Back to Top");
out.println("<A NAME=MIDDLE>");
out.println("<P><P>More Blah Blah Blah<P><P>");
out.println("</body>");
out.println("</html>");
out.close();
}
Thank you in advance,
Val.