Reputation: 257
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.....
Upvotes: 0
Views: 339
Reputation: 3171
you can check below links which should help you achieve your task
Hope this helps !!!
Upvotes: 0
Reputation: 4094
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/[contextroot optional]/yourServletPath.
Upvotes: 1