twilight twilight - 3 months ago 9
Java Question

java adapter not working for condition check

i am faced a problem in the javaAdpter in MFP .
code not execute if statement ..i did not found any cause .

/* Path for method: "<server address>/Trail-Proejct1/adapters/TestAD/users/{username}" */
@GET
@Path("/{username}")
public String helloUser(@PathParam("username") String name){
if(name == "mfp"){

return "good moring" + name;
}
return "good afternoon " + name;
}


enter image description here

[2016-08-09 10:25:41] Adapter build and deploy finished.
[2016-08-09 10:25:59] Starting procedure invocation on MobileFirst Server
[2016-08-09 10:25:59] Not deploying adapter 'TestAD' since it was not changed since last deployment
[2016-08-09 10:25:59] Invoking procedure: '/Trail-Proejct1/adapters/TestAD/users/{username}' of adapter 'TestAD'
[2016-08-09 10:25:59] Server host: Banglafires-MacBook-Pro.local
[2016-08-09 10:25:59] Server port: 10080
[2016-08-09 10:25:59] Parameters: {"QUERY":{},"BODY":"","FORM":{},"HEADER":{},"PATH":{"username":"mfp"}}
[2016-08-09 10:25:59] Procedure invocation finished


output :
enter image description here

Answer

Try

if ("mfp".equals(name)) {

In Java, == is for checking whether two references point to the same object, not for checking whether the contents are the same.