Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2014-02-12
5
Medium Priority
?
314 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 1500 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

Build and deliver software with DevOps

A digital transformation requires faster time to market, shorter software development lifecycles, and the ability to adapt rapidly to changing customer demands. DevOps provides the solution.

Question has a verified solution.

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

I had a project requirement for a displaying a user workbench .This workbench would consist multiple data grids .In each grid the user will be able to see a large number of data. These data grids should allow the user to 1. Sort 2. Export the …
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
Suggested Courses

705 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