you're confusing a and b with the COSETS a+J and b+J. the idea of your proof is correct, but you should be more careful.

suppose J is a prime ideal, and that (a+J)(b+J) = 0+J = J in A/J. this means that ab+J = J, hence ab is in J. Since J is a prime ideal, either a is in J, or b is in J. if a is in J, then a+J = J = 0+J, and similarly for b, so that A/J is an integral domain.

similarly, if we have ab in J, so that ab+J = 0 J = J, then either a+J = 0+J, so that a is in J, or b+J = 0+J, so that b is in J, hence J is a prime ideal.