简体   繁体   中英

Passing the value of query param to string is error

I am working on the same project of scanning the plate number. What I wanted to do is to pass the value of the inputted plate number to string so that I can use it to my other class. The other class is displaying the details of the inputted plate number. On platenumbercheck.java is the class where I want to scan the input of the platenumber. And I want to pass it to String joc so that I can use it to my second class, displaytaxidetails.

Here's the platenumbercheck.java

package com.taxisafe.server;

import java.util.ArrayList;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;

import com.google.gson.Gson;
import com.taxisafe.array.ArrayConnection;
import com.taxisafe.connection.DatabaseConnection;
import com.taxisafe.json.JsonConstruction;
import com.taxisafe.objects.Objects;


//PATH FOR CHECKING PLATE NUMBER

@Path("platecheck")  //for the url

public class PlateNumberCheck {


String joc = check(taxi_plate_no);  //here's the variable I want to pass the platenumber 

@GET 
@Path("/check")
@Produces(MediaType.APPLICATION_JSON) 


public String check(@QueryParam("taxi_plate_no") String taxi_plate_no){

String sagot = "";

if(checkInput(taxi_plate_no)){
    sagot = JsonConstruction.JSONResponse("checked", true);
} else{ 
    sagot = JsonConstruction.JSONResponse("checked", false, "Not in the database");
}
return sagot;

}


private boolean checkInput (String taxi_plate_no){
System.out.println("Check Input");
boolean output = false;
if(JsonConstruction.isNotNull(taxi_plate_no)){
    try{
        output = DatabaseConnection.checkPlate(taxi_plate_no);
    } catch (Exception e){
        output = false;
    }
} else{
    output = false;
}

return output;
}   

}

joc = check(taxi_plate_no); This will not work, u cannot call a function like this put joc=sagot; inside function "check", it should work

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM