Solved

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

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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
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 how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:

930 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

9 Experts available now in Live!

Get 1:1 Help Now