There is a wire which connects the lampholder to ground on the
chassis. Either the wire is corroded, loose, or the socket for the
lamp is corroded. Take the lamp out of the lampholder, and look
carefully at the metal parts where the lamp connects to the
lampholder. Do any look corroded, fuzzy, dirty, or loose? If not,
trace the wire from the lampholder back to where it connects to the
frame of the car, or the motor. Look for frayed, chafed, or kinked
points on the wire. Check to make sure that the wire is securely
attached to the lug where the screw or bolt attaches to the ground
point. If none of these checks reveals a problem, take the vehicle
to an automotive electrical specialist. I had the same problem with
my J30. The driver side headlight would turn on/off. There is a
"relay" that needs to be replaced. It is located on the inside
sidewall of the front wheel of the driver side. It fixed the
problem for me. Hope it works for you as well. There is a TSB
(Technical Service Bulletin) on the headlamp relay of these cars.
Nissan has updated the relay with better material contacts. The
relay is located: Standing in front of the car: The very top right
corner under the hood. Against the firewall, under the windshield,
crammed up against the side of the car.