Junior
Junior

Reputation: 147

How to refresh a jsp page from another jsp page?

I have two jsp pages. groups.jsp and addGroup.jsp

The addGroup JSP page is opened by clicking a button in groups.jsp and after clicking the "OK" button in addGroup.jsp, I'd like to refresh the groups.jsp. How will that be possible?

addGroup.jsp

<script type="text/javascript">
   function refresh() {                         
        //Refresh page implementation here
        window.close();
    }
</script>

//some code here
<table>
  <tr>
  <td>
     <h:commandButton id="buttonOK" value="#{common.ok}" type="button" styleClass="button" onclick="submitForm(); refresh();"/>
  <td>
  </tr>
</table>
//some code here

Upvotes: 4

Views: 6454

Answers (1)

Raman Sahasi
Raman Sahasi

Reputation: 31901

You can use window.opener

objRef = window.opener;

Returns a reference to the window that opened this current window.

Try this in your case:

<script type="text/javascript">
   function refresh() {                         
        //Refresh page implementation here
        window.opener.location.reload();
        window.close();
    }
</script>
...
...

Upvotes: 4

Related Questions