can a 1999 forester computer work in a 2002
Very doubtful, try check the part number, if they match (harness connectors) they might be able to swap, but will surely need reflashing. Usually however older computers never work for newer models or can't be updated to factory specs needed for other engine.
If both engines are SOHC or DOHC there is a small chance it will work. My advice it to use the exact correct part to avoid problems.