Strange problem with request.getParameter

Hi Experts,

I am facing a strange problem with getting values from URL.

So in my controller, I have two methods: getExcel and getChart.

getExcel renders a table in excel sheet and getChart renders a flash chart.

Both the methods have identical structure, except for the return statement.

Problem I am facing is with the variable liabilityCode in getExcel method.
String liabilityCode = request.getParameter("liabilityCode");

I am not able to fetch this value out of URL. where as the same liabilityCode is getting fetched perfectly fine in the method below it (getChart). The strange issue is, except for liabilityCode, I am able to fetch all other parameters. your insight on this would be highly helpful
package com.si.analytics.ui;
 
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
 
 
import javax.servlet.http.HttpServletRequest;
 
import net.sf.json.JSONObject;
 
import org.apache.log4j.Logger;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.ServletRequestUtils;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
 
import com.si.myworld.business.Chart;
import com.si.myworld.dao.ChartData;
 
 
@Controller
public class DetailChartController {
 
	private static final Logger log = Logger.getLogger(DetailChartController.class);
	
	@RequestMapping(value="/excel.html", method=RequestMethod.GET)
	   public String getExcel(HttpServletRequest request, ModelMap model) {
		String chartType = request.getParameter("chartType");
		String chartGroup = request.getParameter("chartGroup");
		String chartSubgroup = request.getParameter("chartSubgroup");
		String timeline = request.getParameter("timeline");
		String liabilityCode = request.getParameter("liabilityCode");
 
		int id = ServletRequestUtils.getIntParameter(request, "chartId", 0);
		String startDt = request.getParameter("startDt");
		String endDt = request.getParameter("endDt");
		
		Chart crt = new Chart();
		crt.setChartGroup(chartGroup);
		crt.setChartSubgroup(chartSubgroup);
		crt.setTimeline(timeline);
		crt.setChartType(chartType);
		crt.setLiabilityCode(liabilityCode);
				
		crt.setChartId(id);
		crt.setStartDt(startDt);
		crt.setEndDt(endDt);
			
		ChartData cd = new ChartData();
	    String chartXml = cd.getChartXml(crt);
	
		String chartDatasource = cd.fetchChartDatasourceName(crt.getChartSubgroup());		
		
		model.put("chartType", chartType);
		model.put("chartGroup", chartGroup);
		model.put("chartSubgroup", chartSubgroup);
		model.put("timeline", timeline);	
		model.put("liablityCode", liabilityCode);
		model.put("detailForm", crt);
	
	
		model.put("chartId", id);
		model.put("startDt", startDt);
		model.put("endDt", endDt);
		model.put("chartDatasource", chartDatasource);
 
			
		String detailRes = cd.getChartDetailDataNew(crt);
		model.put("detailData", detailRes);
		return "excelTable";
	}
		
	   	
	@RequestMapping(value="/chartDetail.html", method=RequestMethod.GET)
      public String getChart(HttpServletRequest request, ModelMap model) {
		String chartType = request.getParameter("chartType");
		String chartGroup = request.getParameter("chartGroup");
		String chartSubgroup = request.getParameter("chartSubgroup");
		String timeline = request.getParameter("timeline");
		String liabilityCode = request.getParameter("liabilityCode");
 
		int id = ServletRequestUtils.getIntParameter(request, "chartId", 0);
		String startDt = request.getParameter("startDt");
		String endDt = request.getParameter("endDt");
		
		Chart crt = new Chart();
		crt.setChartGroup(chartGroup);
		crt.setChartSubgroup(chartSubgroup);
		crt.setTimeline(timeline);
		crt.setChartType(chartType);
		crt.setLiabilityCode(liabilityCode);
				
		crt.setChartId(id);
		crt.setStartDt(startDt);
		crt.setEndDt(endDt);
	
		
		ChartData cd = new ChartData();
	    String chartXml = cd.getChartXml(crt);
				
		//added 7/2/09
		String chartDatasource = cd.fetchChartDatasourceName(crt.getChartSubgroup());		
		
		model.put("chartType", chartType);
		model.put("chartGroup", chartGroup);
		model.put("chartSubgroup", chartSubgroup);
		model.put("timeline", timeline);	
		model.put("liablityCode", liabilityCode);
		model.put("detailForm", crt);
			
		//pp on 7/2/09
		model.put("chartId", id);
		model.put("startDt", startDt);
		model.put("endDt", endDt);
		model.put("chartDatasource", chartDatasource);
 
			
		String detailRes = cd.getChartDetailDataNew(crt);
		model.put("detailData", detailRes);
		
		//breadcrumb
		String breadcrumb = crt.getChartGroup() + ">>" 	+ crt.getChartSubgroup();
		model.put("breadcrumb", breadcrumb);
		
    	return "TestDetail";
    }
 
 
	
	@RequestMapping(value="/chartDetail.html", method=RequestMethod.POST)
	public String setChartPosition(HttpServletRequest request) {				
		return("redirect:/index.html");
	}
	
		
	@ModelAttribute("chartGroups")
	public Collection<String> populateGroups() {
		return populateSubgroups().keySet();
	}
 
	@ModelAttribute("chartSubgroups")
	public JSONObject getSubgroups() {
		return JSONObject.fromObject(populateSubgroups());
	}
 
	    public Map<String, List<String>> populateSubgroups() {
		
		Map<String, List<String>> groups = new HashMap<String, List<String>>();
		groups.put("Payment", Arrays.asList("AUTOPAY", "TXT2PAY"));
		groups.put("Registration", Arrays.asList("REGISTRATION"));
		groups.put("UpgradeChanges", Arrays.asList("UPGRADE_CHANGE"));
		
		return groups;
	}
	    
 
	@ModelAttribute("chartTypes")
	public Collection<String> populateTypes() {
		return Arrays.asList("bar", "line");
	}
 
	@ModelAttribute("timelines")
	public Collection<String> populateTime() {
		return Arrays.asList("Daily", "Weekly", "Monthly", "Quarterly",
				"Annual");
	}
	
	@ModelAttribute("liabilityCodes")
	public Collection<String> populateCustomers() {
		return Arrays.asList("IRU", "CRU");
	}
	
	
}

Open in new window

LVL 10
aman0711Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

SordSordCommented:
In what way are you detecting it is not working? Just on the final output? Or is an exception being thrown somewhere?

Also, are you aware that in your model.put call you spell it "liablityCode" instead of "liabilityCode" (missing one i), although it is spelled the same in both functions, so perhaps it is intentional.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
aman0711Author Commented:
Actually... I put some System.out statements in both the methods... getChart method prints everything including liability Code... getExcel method prints everything other than liability Code
0
SordSordCommented:
My next step would be to use getParameterMap() and dump out all the names and values.

It may also be useful to know how you are making the request. Are you pasting in a link to your browser, or it is being generated programatically?
0
Introduction to Web Design

Develop a strong foundation and understanding of web design by learning HTML, CSS, and additional tools to help you develop your own website.

aman0711Author Commented:
The flow is like this

A.jsp   -->  B.jsp  --> Excel

So B.jsp is getting URL from A.jsp
0
SordSordCommented:
Is there any chance that when A.jsp follows the excel path, it produces a slightly different request URL?

If possible, I think I'd try manually posting the request to B.jsp (using my browser), so I could verify that the problem is with B.jsp (and not with A.jsp).
0
Mick BarryJava DeveloperCommented:
>                 model.put("liablityCode", liabilityCode);

its spelt wrong here as SordSord mentioned earlier
so the libilityCode will not be added to the model, and thus won't be included in the link to /excel.html
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java EE

From novice to tech pro — start learning today.