Solved

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

Posted on 2014-02-12
5
305 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
The viewer will learn how to implement Singleton Design Pattern in Java.
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

623 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