I am passing data from Swing to Servlet using this code:
URL url = new URL(targetURL);
connection = (HttpURLConnection)url.openConnection();
connection.setRequestMethod("POST");
What is that I have to pass to url i.e in place of targetURL(do i need to mention Servlet location) so that I can retrieve values in the servlet…..
You need the address and the servlet path. The servlet path is defined in web.xml
If you have defined a context root you should include it too. Start your servlet in debug mode and enter the url address in the browser, this way you’ll verify it’s correct. URL should look like: http://127.0.0.1/%5Bcontextroot optional]/yourServletPath.