aman0711
asked on
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("liab ilityCode" );
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
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("liab
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");
}
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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?
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?
ASKER
The flow is like this
A.jsp --> B.jsp --> Excel
So B.jsp is getting URL from A.jsp
A.jsp --> B.jsp --> Excel
So B.jsp is getting URL from A.jsp
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).
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).
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER