How to redirect from servlet to project tab panel

Sachin Dhamale January 1, 2014

I call servlet from project tab panel (using AJAX ) update database from servlet.

now i want to come back on project tab panel

i use

resp.sendRedirect(req.getContextPath() + "browse/TEST?selectedTab=com.jira.example.example_ao:wbs-project-tab-panel");

but its not working i want project tab panel page get refreshed

1 answer

1 accepted

0 votes
Answer accepted
Dipti Ranjan Behera
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 1, 2014

Hi Sachin,

I have a query : if you are doing AJAX call then why you are doing page refresh (which is similar to form submission).

you should understand the AJAX & Form submission concept first.

Again , can you elaborate your problem in detail ?

Sachin Dhamale January 1, 2014

Hi Dipti

I have project tab panel in that i display AO table.from this project tab panel i called servlet throgh ajax on event. in servlet i make changes on AO table that changes should be reflecated on project tab panel from which i called servlet

database get modified but that changes is not shown on project ab panel After refreshing that page it show modified changes

<script>
 var data;
		var baseURL=document.getElementById("baseURL").value;
		$("#issuetable tbody").sortable(
		 {
			stop: function( event, ui ) {
				var draggedItem = $(ui.item).find('td').eq(1).text();
				var destinationDI=$(ui.item).prev().find('td').eq(1).text();				
		
				jQuery.ajax({
				  url: "${baseurl}/plugins/servlet/WBS_DNDUpdate",
				  type: "GET",
					data: { source: draggedItem, destination: destinationDI },
				    dataType: "json",
				});
				
				
			}	
			
		});
		
</script>

this is Ajax script which call WBS_DNDUpdate.java servlet after event

on servlet
String url = ComponentAccessor.getApplicationProperties().getString(APKeys.JIRA_BASEURL)+"/browse/TEST";
		System.out.println("==url=="+ url);
		resp.sendRedirect(url);

use this code for redirecting to project tab panel . the class of panel get executed after redirecting but updated data is not able to send to .vm file of that panel

so that updated data is not show on tab panel .

after manually refreshing page it shows.


Dipti Ranjan Behera
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 2, 2014

Hi @Sachin,

The problem here is the ajax call you are making .

a) Just do a direct form submission with form tag , which in turn will refresh the complete page.

b) please see $.get() in the link if it can be helpful : http://api.jquery.com/jquery.get/

Dipti Ranjan Behera
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 2, 2014

@sachin,

Use this ,

var vBrowser = window.open('${req.contextPath}/secure/AddProject.jspa?projectstr='+selectedProjectStr,"_self");

vBrowser.opener=self;

vBrowser.focus();

instead of jQuery.ajax()

Sachin Dhamale January 2, 2014

Hi Dipti

Thanx for u r help. http://api.jquery.com/jquery.get/ this link very helpful

jQuery.ajax({
                  url: "${baseurl}/plugins/servlet/WBS_DNDUpdate",
                  type: "GET",
                    data: { source: draggedItem, destination: destinationDI },
                    success:  function() {location.reload();},
                    dataType: "json",
                });

success: used for calling function after successfull request.

Suggest an answer

Log in or Sign up to answer