How do I set an auitomatic refresh on a jsp page

Posted on 2012-09-11
Last Modified: 2012-09-11
I have some code within a jsp which runs through and creates a html page. However at a certain point within the page I would like it to do a refresh.

Is there a simple way to do this in a jsp?
Question by:Lico_w
    LVL 17

    Assisted Solution

    LVL 1

    Assisted Solution

    by:Siva Kumar Akurati
    Hello Lico_w,

    If you using JSP then use the scriptlet "response.setIntHeader("Refresh", 5);"

    Otherwise If you are using servlets or jsp or struts or any other framework then make it as "response.setIntHeader("Refresh", 5);" in the session or request and display in the corresponding view (jsp) page.

    Author Comment

    Does that have to be used in the head code? I need something that can execute in the main body after some code has ran.
    LVL 3

    Expert Comment

    In PHP I'd throw an:

    echo "<script type='text/javascript'>document.location = '/path/to/this/page.php?a=1';</script>\n"

    to force a refresh.
    LVL 26

    Accepted Solution

    Lico_w:  JSP is written in Java and runs on the web server.  Javascript runs in the browser (the client).  Your questions make it sound as if you want to have some javascript execute in the browser based on some actions the user makes in the browser.  If that's the case, change the zones for the question -- you want Javascript experts, not Java experts.

    If you truly mean that you have a JSP page -- which executes on the server -- then you'll have to explain what you want.  All the above answers are talking about HTML or Javascript which will make the page refresh in the user's browser.

    If you want to display a page to the user with JSP, then display something different, there has to be some interaction with the server.  A JSP runs and creates HTML which is returned by the web server to the browser.  It is not running in the user's browser interactively.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Why You Should Analyze Threat Actor TTPs

    After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

    After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
    Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
    This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
    Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now