Both, plus anchored with a lighter alongside
Of course, while docked and serviced by the dockside crane.
The US Navy perfected underway replenishment (Unrep) during WWII. While originally it was just fuel, by late in the war supplies and ammunition were transferred while underway. Definately by Korea. I have a set of photos showing my father's ship, a WWII era attack transport, highlining 500 pound bombs to a carrier.
Also ships would go to a protected anchorage and have a weapons lighter come alongside. The ammo would be manhandled aboard & stowed. This would likely be done more for the lighter stuff -- 5-inch and smaller. Although on larger ships the boat or plane handling cranes could handle the heavy stuff.
In today's Navy, bombs, rockets, beans, and mail are all delivered via helicopter to the deck of the receiving ship while underway via Vertrep (vertical replenishment)