I'm creating a java desktop application in netbeans for internal use, this is my first java app.
I created a login screen and trying to post user name and password to local wamp server.
I used following http utility class to send post data to server: An HTTP utility class to send GET/POST request
And this is my code to call send Post Request
final String url = "http://localhost/timesheet/api/login";
final String userName = loginName.getText();
final String passwd = pwd.getText();
if (null == userName || userName.equals("")) {
lbl = "Please enter your login name";
} else if (null == passwd || passwd.equals("")) {
lbl = "Please enter your password";
} else {
Map<String, String> data = new HashMap<String, String>();
data.put("user_name", userName.trim());
data.put("pwd", passwd.trim());
String requestURL = "http://localhost/timesheet/api/login";
try {
HttpUtility.sendPostRequest(requestURL, data);
String[] response = HttpUtility.readMultipleLinesRespone();
for (String line : response) {
System.out.println(line);
}
} catch (IOException ex) {
ex.printStackTrace();
}
HttpUtility.disconnect();
This code send request successfully and get responce if i do not pass any parameters or pass only one parameter(Either user_name or pwd) in request.
But when i send both parameter (user_name & pwd) it show 500 internal sever in responce?
I tried searching but not found useful. pleas help me to solve this.
The api code works with php, so don't think issue is with server. something happing in java code that cause 500 internal sever error.
Thanks.
Apache Access Log Entries
127.0.0.1 - - [03/Jan/2014:17:42:32 +0530] "POST /timesheet/api/login HTTP/1.1" 500 1371
127.0.0.1 - - [03/Jan/2014:17:44:07 +0530] "POST /timesheet/api/login HTTP/1.1" 500 1371