Solved

url not showing blank response in firebug but shows result in firefox

Posted on 2014-02-12
5
265 Views
Last Modified: 2014-02-28
HI,
In my web application there is a Autosuggestion.
But it hangs if i type any city name like Delhi.

I see the following url in the firebug on typing the city name :
http://local.yatra.com:8080/flights-india-yt/autosuggest/autosuggestion?q=del&limit=10&url=&pdt=int

In firebug under the response tab its blank.

But if i directly type that url in the firefox it shows result.
What could be reason for that ?

Thanks
0
Comment
Question by:Rohit Bajaj
  • 3
5 Comments
 
LVL 86

Expert Comment

by:CEHJ
ID: 39852731
In what way is Java involved in this?
0
 

Author Comment

by:Rohit Bajaj
ID: 39852735
The service hits the following code :

package com.yatra.products.air.web.controller;

import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.yatra.platform.commons.dao.impl.MasterDataBean;
import com.yatra.products.air.service.AutoLookService;
import com.yatra.products.air.util.FlightConstants;



@Controller
@RequestMapping("autosuggest/*")
public class AutoSuggestionController extends BaseController{

	/** The logger. */
	private Logger logger = Logger.getLogger(AutoSuggestionController.class);

	@Autowired MasterDataBean masterDataBean;
	
	/** Variable for holding the AutoLookService */
	private AutoLookService autoLookService;

	/**
	 * Setter for AutoLookService
	 * 
	 * @param autoLookService
	 */
	@Autowired
	public void setAutoLookService(AutoLookService autoLookService) {
		this.autoLookService = autoLookService;
	}

	@RequestMapping(value = "autosuggestion", method = RequestMethod.GET)
	public @ResponseBody String getAutoSuggestion(HttpServletRequest request, HttpServletResponse response, Model model) {
		
			List<Map<String, String>> autoLookSearch;
			String result = "";
			String productType = request.getParameter("pdt");	
			String key = request.getParameter("q");
			String isKeyAirportCode = request.getParameter("isqAirportCode");
			String recordSeparator = request.getParameter("rs");
			
			if(key != null && productType != null){
				
			if(isKeyAirportCode != null && isKeyAirportCode.equals("true")) {
				autoLookSearch = autoLookService.getAutoLookSearchByAirportCode(key,
						productType);
			}else {
				autoLookSearch = autoLookService.getAutoLookSearch(key,
						productType);
			}
				logger.debug("autoLookSearch size is "+ autoLookSearch.size());
				for (int i = 0; i < autoLookSearch.size(); i++) {
					Map<String, String> map = autoLookSearch.get(i);
					result += map.get(FlightConstants.AUTO_SUGGEST_KEY);
					result += ":";
					result += map.get(FlightConstants.AUTO_SUGGEST_DISPLAY_STRING_KEY);
					if(recordSeparator!=null)
						result += recordSeparator;
					else
						result += "\n";
				}
				response.setCharacterEncoding("UTF-8");
			}
			else{
				
				logger.error("either parameter q or pdt is missing in request");
				result = null;
			}
			
			return result;

	}
	
	@RequestMapping(value = "getCountryCode", method = RequestMethod.GET)
	public @ResponseBody String getCountryCode(HttpServletRequest request, HttpServletResponse response, Model model) {
		String aCode = request.getParameter("airportCode");
		String countryCode = masterDataBean.getCityMap().get(aCode).getCountryCode();
		return countryCode;
	
	}

}

Open in new window

0
 

Author Comment

by:Rohit Bajaj
ID: 39852750
Sory for the typo in the heading
url is showing blank response in firebug.
But shows result in firefox
0
 

Author Comment

by:Rohit Bajaj
ID: 39852786
I was opening my site with url : dev.yatra.com
In firebug the url fired for autosuggestion was :

http://local.yatra.com:8080/flights-india-yt/autosuggest/autosuggestion?q=del&limit=10&url=&pdt=int

When i opened the site with local.yatra.com the problem was resolved.

I think its something cross domain issue.

But dont know the exact reason for this to happen.
0
 
LVL 2

Accepted Solution

by:
c_kedar earned 500 total points
ID: 39854408
As rightly suspected, it must be cross domain scripting issue.
A page can do Ajax request (XHR) only to the same domain as that of the document.

You can verify this by either inspecting access logs or by adding a debug log/sop in you handler code.

Access log entry/debug log will be present when you use the URL directly in browser but it will absent when it is called as XHR from page, indicating that browser did not send the request to server.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

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 …
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…

706 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

16 Experts available now in Live!

Get 1:1 Help Now