Solved

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

Posted on 2014-02-12
5
299 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

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Detect Closed Loops (circles, figure-8s, etc) in PNG Images 6 96
servlet and mdb, jms error 1 82
web project error add remove 1 84
Session in java desktop 5 37
INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
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…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
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…

738 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