Hi am sending a url using apache HttpClient by using following code but it has been showing a exception :java.net.URISyntaxException:
Illegal character in query at index 70: http://192.155.2.144:8080/SDAX/homePage.do?actionFlag=istrict&&MSG=1|Bdrtfggf|254td|return|null|null|null
Please help me where iam doing the problem. the following code i am sending a URL
String MSG="1|Bdrtfggf|254td|return|null|null|null" ;
String url="http://192.168.2.144:8080/SDAX/homePage.do?actionFlag=edistrict&&MSG="+MSG;
System.out.println("Url is"+url);
//String url = "http://192.168.0.6:8084/NRC_NEW_SEARCH/getVillageList.req?dist_id=1";
//String url="http://192.168.0.85:8080/poly/web/";
//FacesContext.getCurrentInstance().getExternalContext().redirect(url);
//ExternalContext context = FacesContext.getCurrentInstance().getExternalContext();
//context..redirect(url);
HttpRequestBase request = new HttpGet(url);
/*HttpParams params = new BasicHttpParams();
params.setParameter("dist_id", "1");
request.setParams(params);*/
HttpClient httpClient = new DefaultHttpClient();
httpClient.execute(request);
You should encode
the MSG
string before creating a URL
from it.
String encodedMSG = URLEncoder.encode(MSG, "UTF-8")
String url="http://192.168.2.144:8080/SDAX/homePage.do?actionFlag=edistrict&&MSG="+ encodedMSG;
Edit
There won't be any problem in retrieving the data after encoding. If you have programmed this servlet homePage.do
then you should use URLDecoder.decode()
method in it.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.