Forbid refresh in jsp

hi
I have one jsp with some data.when I refresh jsp with button of browser.The result is:in jsp have data twise.
when i refresh with browser button servlet execute last action.I dont like this.
I want to forbid refresh from browser in this jsp,but this is silly,and i dont know how this.
Any suggestions for that how forbid refresh in jsp or some other decision

Web apps have to be able to survive all kinds of unexpected user actions with the browser, refresh, back and forward buttons, bookmarking pages in the middle of a conversation, openning a second window on the same page and so on.
So you need to write your JSP with fewer assumptions about the data it's invoked with.
Beyond that we'd need more details.

Similar Messages

  • How to refresh frame1.jsp from frame2.jsp?

    Hi,
    I have main.jsp that holds frameset that contains "frame1.jsp" and "frame3.jsp".
    on submit at "frame3.jsp" it goes to "frame2.jsp", now I want to refresh "frame1.jsp"
    p.s.
    I don't mind to refresh the "main.jsp", I guess that will refresh the frames inside him too - include "frame1.jsp".
    BUT, how can I do it?

    Hi,
    this seems to be a HTML/JavaScript problem, not JSP related.
    The file frame2.jsp could refresh frame1.jsp using "onLoad" on the <body> tag.
    You could also do this before loading frame2.jsp, while pressing the submit button. Instead of using a submit buton you could use a JavaScript function that would submit the form and reload another frame.
    Good Luck!
    PS: If this isn't enough help, plese post the contents of main.jsp (the frameset) so you can get some real code back.

  • Refreshing Parent.jsp and forwarding to Child.jsp

    Hi
    I have a parent.jsp where I provide criteria to query and export the data to excel. If the resultset is null I forward to parent.jsp with error message, but if there is data I forward to child.jsp.
    If in the first attempt there is no data and display of error message in parent.jsp and in the subsequent second attempt I change the selection criteria and get the data report in excel format, but the error message displayed in parent.jsp for the earlier transaction remains the same i.e. parent.jsp should ideally refresh and then forward to child.jsp.
    Currently I am using the following code and controlling it with a script that is called on click of submit i.e. I set the text (error text) value to null. Is there a better way to achieve this? Kindly help
    <%if (error != null) {%>
    <table>
    <tr>
    <td>
    <input type="text" name="errorMsg"
    style=" color:red; font-size: 8pt; FONT-FAMILY: verdana, helvetica;font-style: TT; border:'0'; font-weight: Bold"
    value='<%= error %>'
    size="141" readonly="readonly"/>
    </td>
    </tr>
    </table>
    <%}%>

    Thanks a lot frndz.. for your reply.. but both ways I tried its not working ..Devendra I went thru the code given there in the link but it couldn,t work... I tried for window.opener.refresh(). In spite of refreshing the parent jsp and getting the pop up closed ,it displayed the the refreshed parent JSP in the pop up window. keeping parent JSP intact..
    Any other alternative can anyone advise... :)

  • Prolem with refreshing my jsp page

    Refreshing the page
    I have a jsp page with few buttons(like add, delete, save), during loading time, it loads data from database and display in a table of row data,when I clicked the delete button to delete a row, it removes a row of data from my database, but it still displays that deleted row, bcoz page has not been refreshed. Now I wrote 2 java script function, one which invokes my delete function in my Action class and another I am trying to again load the page after delete, so that I can get fresh data. But its not happening, do you have any idea, where am I going wrong, or how can I refresh my jsp page after I delete a row. I am getting my data from database and after that I put in session.
    Here is my small code base
    function invokeICCanAssignmentDeleteFunction()
          func();
          initialise();
    // this method deletes my data from DB
        function func()
         alert("alert 1");
        document.forms[0].action='/eta/canAssignment.do?mode=icCanAssignmentDelete';
         alert("alert 2");
    // this method initialise my form bean taking data from db and put in session inside my action class
        function initialise()
         alert("alert 3");
        document.forms[0].action='/eta/canAssignment.do?mode=icCanAssignment';
         alert("alert 4");
        }

    The following two javascript lines will only set the action value of the form and does nothing else. No server call will be made.
    document.forms[0].action='/eta/canAssignment.do?mode=icCanAssignmentDelete';
    document.forms[0].action='/eta/canAssignment.do?mode=icCanAssignment';You need to submit the form to make a server call. For Example:
    document.forms[0].action='/eta/canAssignment.do?mode=icCanAssignmentDelete';
    document.forms[0].submit();Google Javascript tutorials for more.

  • Need to refresh the jsp page

    Hello Everyone,
    I am not sure if I can tackle the below issue with just html or I need to control it throught my servlet, so posting it on this forum, in case it is a pure html issue, please let me know.
    So here is the current situation:
    My jsp page gets data from servlet and displays it in a html table. The fields are criteria, median, average...cells of average, median etc are color coded, green, yellow or red, depending on whether the criteria is met or not.
    on wish list:
    I want the column "criteria" to be of text type so that the user can change the criteria value and see what effect does it have on the colors of columns "average", "median" etc. I do not want to write this changed criteria value back to db, I just want my jsp page to refresh every time user changes value in criteria text box and recalculate the color code for the rest of the columns.
    Here is what my jsp page looks like
    <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
    <%@ taglib uri="http://paginationtag.miin.com" prefix="pagination-tag"%>
    <html>
    <body>
      <table border="1">
        <c:forEach items="${sheetDataList}" var="releaseData">
        <tr>
          <td align="center"><input type="text" name="newcriteria" value="${releaseData.releasecriteria}" size="25"></td>
          <c:set var="yellowmark" value="${0.25*releaseData.releasecriteria+releaseData.releasecriteria}"/>
          <c:choose>
            <c:when test="${releaseData.average lt releaseData.releasecriteria}">
              <td bgcolor="green" align="center"><c:out value="${releaseData.average}"/></td>
            </c:when>
            <c:when test="${releaseData.average lt yellowmark}">
              <td bgcolor="yellow" align="center"><c:out value="${releaseData.average}"/></td>
            </c:when>
            <c:when test="${releaseData.average gt yellowmark}">
              <td bgcolor="red" align="center"><c:out value="${releaseData.average}"/></td>
            </c:when>
          </c:choose>
      </table>
    </body>
    </html>Thanks.

    I don't know what you are doing wrong in your code, but it seems like you are calling the JS function correctly. My feeling is there is some JS error occurring, maybe use a javascript debugger or some alerts to see where the problem is. I made as close a copy of your code I could (with some improvised improvements for keeping track of row counts and accessing the the values for the first 2 columns of the table). At the top I filled to Lists with data so I could cycle through the rows and columns. Then I do the JavaScript and the CSS, followed by the table generation.
    <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
        pageEncoding="ISO-8859-1"%>
    <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <%
        java.util.List<java.util.List<luke.steve.RowObject>> sheetDataList = new java.util.ArrayList<java.util.List<luke.steve.RowObject>>();
        for (int r = 0; r < 10; r++) {
            java.util.List<luke.steve.RowObject> userActionData = new java.util.ArrayList<luke.steve.RowObject>();
            for(int c = 0; c < 5; c++) {
                 userActionData.add(new luke.steve.RowObject());
            sheetDataList.add(userActionData);
        request.setAttribute("sheetDataList", sheetDataList);
    %>
    <html>
      <head>
        <script type="text/javascript">
        <!--
          function setAllColors() {
            var currentRow = 1;
            var row = null;
            while((row = document.getElementById("row"+currentRow)) != null) {
              setColors(currentRow);
              currentRow++;
          function setColors(currentRow)
            var criteria = document.forms[currentRow-1].criteria.value;
            var yellowLine = 1.25 * criteria;
            var row = document.getElementById("row"+currentRow);
            var currentCol = 2;
            do {
              var col = row.cells[currentCol];
              var colValue = col.innerHTML * 1;
                   if (colValue <= criteria)  col.className = "green";
              else if (colValue < yellowLine) col.className = "yellow";
              else                            col.className = "red";
              currentCol = currentCol + 1;
            } while(row.cells[currentCol] != null);
        //-->
        </script>
        <!-- Make the clock look the way you want it to. -->
        <style type="text/css">
          .green
           background-color: green;
          .red
            background-color: red;
          .yellow
            background-color: yellow;
        </style>
        <title>Color Switcher</title>
      </head>
      <body onload="setAllColors();" onunload="">
        <table border="1">
          <tbody>
            <c:forEach var="userActionData" items="${sheetDataList}" varStatus="rowCounter">
              <tr name="row${rowCounter.count}" id="row${rowCounter.count}">
                <td>${userActionData[0].userAction}</td>
                <td><form onsubmit="setColors(${rowCounter.count}); return false;"><input name="criteria" type="text" value="${userActionData[0].releaseCriteria}"/></form></td>
                <c:forEach var="releaseData" items="${userActionData}" varStatus="colCounter">
                  <td>${releaseData.ninetyPercentile}</td>
                </c:forEach>
              </tr>
            </c:forEach>
          </tbody>
        </table>
      </body>
    </html>I made a dummy class called luke.steve.RowObject to hold the data (represents on releaseData object). The class just generates a bunch of random numbers for this test:
    package luke.steve;
    public class RowObject {
         public Integer getReleaseCriteria() {
              return Double.valueOf(Math.random()*500.0).intValue();
         public Integer getNinetyPercentile() {
              return Double.valueOf(Math.random()*500.0).intValue();
         public String getUserAction() {
              return "Action "+Double.valueOf(Math.random()*10.0).intValue();
    }In this example it works in FF3 and IE7 (though it looks nicer in FF3).

  • Refreshing included JSP file

    Hi,
    I've created a simple word-verification login system to stop robots from trying out various password combo's on a user's account.
    I've created a separate JSP page that randomly chooses an image from a database, sets a session variable to the word that is spelt in the image. Then when the user types in the word it simply checks that the word the user typed matches the session variable.
    Here's a snipet from this file: -
    login_image.jsp
    String [] sImageText = {
    "flusessn",
    "mises",
    "appalli",
    "encirs",
    "peromm"
    // create random number between 0-5
    Random rand = new Random();
    int nImageNumber = rand.nextInt(6);
    session.setAttribute( "imageword", sImageText[nImageNumber] );
    response.sendRedirect( "images/login/Captcha" + nImageNumber + ".jpg" );The image is displayed in the login page as follows:
    login.jsp
    <img src="login_image.jsp" />Whe the user enters their username, password and word verification it is processed in a separate JSP file: -
    process_login.jsp
         String sWordVerification = request.getParameter("securitycode");
         String sTheWordVerification = (String)session.getAttribute( "imageword" );
         if ( !sTheWordVerification.equalsIgnoreCase( sWordVerification ) ) {                response.sendRedirect( "login.jsp?worderror=true" );
         } else {     
    .The system works ok. My problem arises if the user enters the wrong word, they are shown an error message on the login.jsp page. However, the login image doesn't change. Any idea how I can make the image refresh each time the login.jsp page is loaded?
    Many thanks

    Thanks.
    I've managed to sort it using javascript. It's a bit messy, but it works. All the changes are made to login.jsp: -
    <script language="JavaScript">
    <!--
    var sURL = unescape(window.location.pathname);
    function doLoad()
        setTimeout( "refresh()", 1 );
    function refresh()
        window.location.href = sURL + "?worderror2=true";
    //-->
    </script>
    <%                                   
    String sError = request.getParameter("worderror");
    if ( sError != null ) {                    
    %>
    <meta http-equiv="refresh" content="1" >
    <script>
         doLoad();
    </script>
    <%
    String sError2 = request.getParameter("worderror2");
    if ( sError2 != null ) {               
         out.println( "<div class=\"redtext\" align=\"center\"><p>The word verification failed.  Please try again.</p></div>" );                              
    %>Here's how it works: -
    - User enters word verification in login.jsp
    - Posted to process_login.jsp
    - If the words don't match then redirect to login.jsp?worderror=true
    - login.jsp detects the worderror=true and runs the following script
    <meta http-equiv="refresh" content="1" >
    <script>
         doLoad();
    </script>
    - The doLoad() method refreshes the login page, including the login image using the refresh method
    - It redirects to window.location.href = sURL + "?worderror2=true";
    posting worderror2=true prevents login.jsp from entering an infinate loop.
    aaaaaaaand relax.....

  • Firefox dose not refresh while ie refreshes the JSP page

    Hiii,
    I think I am in a little tricky situation here and need for your advice,
    here is the situation...
    I have a small .jsp page that contains a little jsp code and a little html code ...
    the main function of the jsp part is the adjust the "refresh content" destination...
    this is the code ..
    if (abs==1
         toGo = "a.jsp";
    if (abs==2)
              toGo = "b.jsp";
    if (abs==3)
                   toGo = "c.jsp";
    if (abs==4)
         toGo ="d.jsp";
    %>
    <meta http-equiv="REFRESH" content="10; url=<%=request.getContextPath()%>/en/<%=toGo%>">
    this code works fine in ie,
    ie, refreshes the page and decide where to go ...
    however firefox (and mozilla, may be netscape too) .. dose not refreh .. so the page stays...
    actually they are porbably refreshing but it seems that they are not running jsp again and again ..
    where is the problem ? ..
    How should I solve this problem ...
    Thank you..

    actually it makes sense but It is not working..
    event if I adject the refresh path like,
    <meta http-equiv="REFRESH" content="10; url=http://www.yahoo.com/<%=request.getContextPath()%>/<%=lang%>/event/Proposal/<%=toGo%>">
    it is not reporting an error... .. (page not found :) ) .... but it refreshes... I mean If I change the content of the html part, I get the changes from browser.. but the page is still there..

  • Refreshing a JSP that lives on a network drive

              We're running WLS 6.0sp2 as a service, and have an exploded web application residing
              on a mapped drive. We use AutoExNt to set up the mapped drive before starting
              WLS.
              When the JSP is updated by a content management system that is responsible for
              keeping track of the file, WLS doesn't notice that the filedate has changed, and
              does not recompile the JSP.
              We have verified that the datestamp on the file changes. Our refresh time is
              set to 1 (second). Does anyone have an idea as to what's happening?
              Ronak Shah
              

    Great thanks. It is actually the drive that holds my music. I don't need the songs backed up through time machine - far too much time and footprint, but I do want the library files backed up to maintain playloists, ratings, etc... I separated the music files from the library files and then selected the music files for exclusion. iTunes still sees the music files (I manage them vice letting iTunes do it. It has a nasty habit of splitting up multiple albums and placing non-compilations into the Compilations folder, etc...) I haven't run TM yet, but this gives all the appearance of working at this point. I will update and mark the question answered once I confirm.

  • Refresh reported Jsp Err, not OracleJSP java.io.FileNotFoundException

    i followed the instruction of cue card: Build a Mobile Browser Application with Oracle ADF, using Jdev 11.1.1.2, runing in integrated WL Server.
    the initial browse of page tested ok, but when refresh or goback then reported Jsp Err, OracleJSP java.io.FileNotFoundException.
    how to solve the problem, or i did some mistake in developing application or configuring WL Server? it trouble me for a few days
    thanks
    nicholas
    fixed. it seems that no adf should be introduced into the project.
    nick

    Good morning yassen,
    Please read [url https://forums.oracle.com/forums/thread.jspa?messageID=3555226&#3555226]this link. As it explains and I believe, you have a space in the name of your file. Rename your file to NOT have a space and you should be OK.
    Don.
    REWARDS: Please remember to mark helpful or correct posts on the forum, not just for my answers but for everyone! :)

  • Attribute created by 'SELECTED IN QUERY' dont refresh in jsp

    Hello,
    I have an application with:jdev 10.1.2 and jhs 10.1.2
    for the management of the following tables:
    CREATE TABLE PROJECTS(
    ID NUMBER(6),
    DESCRIPTION VARCHAR2(100)
    CREATE TABLE EMPLOYEES(
    ID NUMBER(6),
    PROJECT_ID NUMBER(6)
    In jhsStruture file I create 1 group for ProjectView (layout:table-form)
    and 1 sub-group for EmployeeView (layout:table)
    IN the query for PROJECTVIEW I ADD AN ATTRIBUTE: Employees =>
    (SELECT COUNT(ID) FROM EMPLOYEES WHERE PROJECT_ID = ID)
    Then when I add an employee in the application (Employee Tab) and I go to projects tab, the attribute
    EMPLOYEES dont increase...
    NOW, i want that this attribute refresh..
    HOW TO CONFIGURE THIS FEATURE PLEASE?...
    THIS IS POSSIBLE?
    thanks,
    Rigoberto

    Rigoberto,
    This sounds like a JDeveloper/ADF issue that is not related to JHeadstart. Try if you can reproduce the problem in the ADF BC Tester (right-click your Application Module and choose Test).
    If so, can you please log a TAR at MetaLink ( http://metalink.oracle.com/ ), or ask this question at the JDeveloper forum at http://otn.oracle.com/discussionforums/jdev.html ? Thanks.
    kind regards,
    Sandra Muller
    JHeadstart Team
    Oracle Consulting

  • How to diable refresh in jsp

    hi all,
    i want to disable the refresh button ... i am inserting into the db in the page ... i want the insertion only once .... as i am using text datatype i cant compare by db before insertion

    you could do a redirect after you execute the database logic. Then when the user refreshes the page, he only refreshes the redirect.
    A safety prevention would be to store a unique number somewhere in the database that you generate in your code (current timestamp would do the trick) and then put as a hidden field in your form. When the user submits the form the first time, the number won't exist and you insert. The second time the same form is submitted due to a refresh the number will exist and you simply do no transaction.

  • Jow to refresh a jsp

    Hi,
    I'm new to Jdeveloper.
    I have a jsp search form which accepts user's criteria and retrieves data from database via JDBC onto the same jsp form. What I want to do is when user clicks on one of my links (say Form Type and Table Type) the result set will be displayed with form layout or table layout depending on the link being click.
    Any help would be appreciated.

    Ideally you need to be using a page controller like Struts to handle this. Then based on a parameter on the link you can decide what data to prepare for the page to display.
    Alternatively you could use JSTL tags to check the value of a url parameter and carry out alternative operations / layouts - e.g. using the <c:choose> tag.
    See the Sun website for more detail on JSTL.

  • JSP page not refreshing in browser

    Everytime I edit a JSP file, and try to refresh the JSP in the browser, I don't get an updated version... just the original page that I viewed first. Anyone got a solution?
    I tried deleting the work directory under the %tomcatHome% directory, and that seems to work until I view the page, and tomcat creates this work directory again. So when I try to refresh the page, because the work folder is still there, the page does not get refreshed. Weird... any solutions? Thanks again.

    I'm not sure if your using Tomcat or not but if you are give this a try:
    The ROOT context is the default Web application in Tomcat, and is convenient to use when you first learning about servlets and JSP (although you'll use your own Web applications once you're more experienced). The default Web application is already enabled in Tomcat 3, Tomcat 4.0.1-4.0.3, and Tomcat 4.1. But, in Tomcat 4.0.4 it is disabled by default. To enable it, uncomment the following line in install_dir/conf/server.xml:
    <Context path="" docBase="ROOT" debug="0"/>
    Taken from: http://www.moreservlets.com/Using-Tomcat-4.html#Enable-Root-Context
    This will make the server request a new page every time, not recommended for production apps but for development it will make life easier.

  • Refreshing JSP file for an exploded WAR without undeploying the WAR - 7210

    The weblogic.Deployer utility with -activate option does redeploy my application. How do I prevent redeployment while refreshing. I'm using Weblogic 7.0.0.0.
              Thanks
              Senthil Kumar.S
              

    Thanks mbg for your response.
              Our production environment does not support the option a. We use the
              option b approach.
              My config.xml looks like this for the webapplication
              <Application Deployed="true" Name="oas"
              Path="/tmp/senthil/oas3.7.1.5"
              StagedTargets="DOAS_MT_021_20501" TwoPhase="true">
              <WebAppComponent Name="oas" Targets="DOAS_MT_CLUSTER_1"
              URI="oas"/>
              </Application>
              I performed the following steps..
              1) Modified the following jsp file on the admin.
              /tmp/senthil/oas3.7.1.5/oas/customercare/contactus.jsp
              2) Ran the following command on the admin
              java weblogic.Deployer -adminurl t3://n.n.n.n:20501 -user system
              -password weblogic -name oas -activate customercare/contactus.jsp
              after running the command,
              I was able to identify the corresponding jsp file immediately updated
              on the managed instance under the stage folder. But the class file on
              the stage folder was not updated and neither the class file on the
              .wlnotdelete folder. I was using the pagecheckseconds on the
              weblogic.xml as -1.
              I stopped both the admin and manage, modified the pagecheckseconds to
              1 Hour and when I performed same steps as before, I was able to see
              the jsp file updated and also getting compiled (when accessed) and
              serving the updated content. Also the user session was kept intact.
              i.e. no interruption to the session. This was what I was expecting
              for. The strange thing is, it didn't wait for one hour to compile. It
              was compiling immediately when I accessed the modified jsp file. I'm
              not sure whether it would behave the same way if I put that value as 1
              day or some very big +ve value.
              I'm not sure whether I'm doing the right way. i.e. changing the
              pagecheckseconds to ve value. Also I'm not sure whether the ve value
              for the pagecheckseconds would create impact on performance.
              Thanks for your time.
              Senthil Kumar.S
              "Mark Griffith" <[email protected]> wrote in message news:<[email protected]>...
              > Ahh clarity. :D
              >
              > You can:
              >
              > a) deploy your exploded web app with -nostage option. Meaning nocopy, or in
              > otherwords "WLS when you deploy this Application to each server in the
              > cluster, don't copy the bits to each server, just deploy from this src".
              > What that means is that the path that maps to the directory of your webapp
              > must be accessible, or resolvable on each server that it is deployed to.
              >
              > java weblogic.Deploy .... -nostage -activate -source /myapps/mywebapp
              >
              > so that /myapps/mywebapp must be resolvable on each server that it is
              > deployed to. You can accomplish this via a shared network directory for
              > /myapps or you can copy and create /myapps your self on each of the
              > machines.
              >
              > b) deploy your exploded web app with -stage option. Meaning copy, or in
              > otherwords "WLS when you deploy this Application to each server in the
              > cluster, do copy the bits from my "source" to each server" In this case,
              > you will have to use refresh
              >
              > What command did you execute on with weblogic.Deployer
              >
              > Cheers
              > mbg
              >
              >
              >
              > "Senthil Kumar S" <[email protected]> wrote in
              > message news:[email protected]...
              > > Let me rephrase my requirement..
              > > My production environment is Weblogic 7.0.1 with a clustered environment
              > with exploded WAR.
              > > How do I refresh my jsp files with out undeploying my web application?
              > >
              > > When I tried by modifying the jsp file on the exploded directory on the
              > admin and ran the weblogic.Deployer utility, it successfully updated the
              > copy on the managed instance (I verified by checking the stage directory).
              > But the jsp was never recompiled on the managed instance and it was serving
              > old content.
              > >
              > > Thanks
              > > Senthil Kumar.S
              

  • JSP refresh from servlet.

    Hi everyone
    I'm creating a web application that is a combination of jsp pages and servlets.
    On one of the jsp pages I add contact details of a person in a form, then when submitted it goes to the servlet which adds the new contact into the database,
    after the servlet entered the data it redirects to the ContactList.jsp page, but it doesn't show the newly created user, I need to refresh the page manually to see the users.
    How can I from the servlet when I redirect to the ContactList.jsp page, refresh the ContactList.jsp page to show the newly created contacts well?
    Here is the servlet which gets called when I submit the jsp form.
    package contacts;
    import javax.servlet.*;*
    *import javax.servlet.http.*;
    import java.io.*;*
    *import contacts.*;
    public class NewContactServlet extends HttpServlet
         public void doPost(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException
              res.setHeader("Expires", "Tues, 01 Jan 1980 00:00:00 GMT"); //no cache allowed
              Contacts contacts = new Contacts();
              ContactsData contactsData = new ContactsData();
              contacts.setContactName(req.getParameter("contactName"));
              contacts.setCompany(req.getParameter("companyName"));
              contacts.setWorkNumber(req.getParameter("workNum"));
              contacts.setCellNumber(req.getParameter("cellNum"));
              contacts.setFaxNumber(req.getParameter("faxNum"));
              contacts.setEmail(req.getParameter("email"));
              contacts.setCountry(req.getParameter("country"));
              contactsData.addContact(contacts);
              res.sendRedirect("ContactList.jsp");
    }

    Hi manuel.leiria
    Here is my code for refreshing the jsp, it is working.
    Just tell me what you think, if it's the right way.
    The servlet that sets the attribute
              session.setAttribute("contactsSession","add");
              res.sendRedirect("ContactList.jsp");The jsp page that gets the page.
              <%
              String refreshSession = (String)session.getAttribute("contactsSession");
              if(refreshSession != null && refreshSession.equals("add"))
                   %>
                   <body onload="window.location.reload(true);">
                   <%
                   session.removeAttribute("contactsSession");
              else
                   %>
                   <body>
                   <%
              %>

Maybe you are looking for