title: How do I pass multiple parameter in URL?
body: <p>I am trying to figure out how to pass multiple parameters in a URL. I want to pass latitude and longitude from my android class to a java servlet. How can I do that?</p>
  
  <pre><code>URL url;
  double lat=touchedPoint.getLatitudeE6() / 1E6;
  double lon=touchedPoint.getLongitudeE6() / 1E6;
  url = new URL("http://10.0.2.2:8080/HelloServlet/PDRS?param1="+lat+lon);
  </code></pre>
  
  <p>In this case output (written to file) is <code>28.53438677.472097</code>.
  This is working but I want to pass latitude and longitude in two separate parameters so that my work at server side is reduced. If it is not possible how can I at least add a space between <code>lat</code> &amp; <code>lon</code> so that I can use <code>tokenizer</code> class to get my latitude and longitude. I tried following line but to no avail.                        </p>
  
  <pre><code>    url = new URL("http://10.0.2.2:8080/HelloServlet/PDRS?param1="+lat+" "+lon);
  output- Nothing is written to file
          url = new URL("http://10.0.2.2:8080/HelloServlet/PDRS?param1="+lat+"&amp;?param2="+lon);
  output- 28.534386 (Only Latitude)
          url = new URL("http://10.0.2.2:8080/HelloServlet/PDRS?param1="+lat+"?param2="+lon);
  output- 28.532577?param2=77.502996
  </code></pre>
  
  <p>My servlet code is as follows:</p>
  
  <pre><code>req.setCharacterEncoding("UTF-8");
  resp.setCharacterEncoding("UTF-8");
  final String par1 =  req.getParameter("param1");
  final String par2 = req.getParameter("param2");
  FileWriter fstream = new FileWriter("C:\\Users\\Hitchhiker\\Desktop\\out2.txt");
  BufferedWriter out = new BufferedWriter(fstream);
  out.write(par1);
  out.append(par2);
  out.close();
  </code></pre>
  
  <p>Also I wanted to the know is this the most safe and secured way to pass the data from android device to server.</p>