Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Reload servlet to a specific area on the page

843840Jun 4 2002 — edited Jun 5 2002
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.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 3 2002
Added on Jun 4 2002
8 comments
330 views