# Counter-example: If $J$ is prime then $f^{-1} (J)$ is prime. $f$ need not be unital.

Let $R$ and $S$ be commutative with 1 and  $f:R\rightarrow S$ is a ring homomorphism which need not be surjective or unital i.e. $f(1_R)=1_S$

I know that for surjective or unital ring homomorphisms the statement - "If $J$ is prime then $f^{-1} (J)$ is prime" - holds true.

However, if f need not be surjective or unital, are there any counter examples for the above statement?

Yes: the zero map would then be a morphism of rings, and the preimage of every prime ideal is then $R$, which is not a prime ideal (by definition)
To give a less trivial example: Take i.e. integral domains $R_1, R_2$. Then the inclusion $i : R_1 \to R_1 \times R_2$ is a morphism (which doesn't send $1_{R_1}$ to $1_{R_1 \times R_2} = (1_{R_1}, 1_{R_2})$). Moreover, $R_1 \times \{0\}$ is a prime ideal whose preimage is $R_1$ which is not prime.
Edit: This is never the case if the map isn't unital. Let $\psi : R \to R'$. Then $\psi(1) = e$ is idempotent, i.e. $e^2 = e$. Then also $1-e$ is idempotent and we have a decomposition $R' = eR \oplus (1-e)R = R_1 \oplus R_2$, which is non-trivial if $e \neq 0_{R'},1_{R'}$. It is a well-known fact, that the prime ideals in $R_1 \oplus R_2$ are of the form $P_1 \oplus R_2$ or $R_1 \oplus P_2$ for a prime ideal $P_i \subseteq R_i$. So, take a prime ideal $P \subseteq R_2$, then $R_1 \oplus P$ is prime in $R' = R_1 \oplus R_2$ and its preimage under $\psi$ is $R$.