Salman Salman - 1 year ago 74
Java Question

pass arithmetic operation with http get request

I am required to pass an arithmetic operation like

to a restful back-end and receive the result. I know that a simple operation can be handled in frontend using javascript, but i just want to follow the requirement.

I send the operations with the following uri:


and in the back-end i have:

public String getAnswer(@RequestParam("question") String question){

System.out.println("recieved question is: "+question);
return botService.Evaluator(question);


When i print the
it is like
2 3
so there is no operation there.
And the component complains with:

javax.script.ScriptException: <eval>:1:2 Expected ; but found 5
2 5
^ in <eval> at line number 1 at column number 2

So, why the
is missing?
and how can i fix it?

Answer Source

Use the URLEncoder class to make sure any special characters are encoded safely for transport.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download