"The practice reached its zenith during World War 2, when the availability of man-portable radio systems and sophisticated relay networks allowed forward observers to transmit targeting information and provide almost instant accuracy reports—once troops had landed. Battleships, cruisers and destroyers would pound shore installations, sometimes for days, in the hope of reducing fortifications and attriting defending forces. Obsolete battleships unfit for combat against other ships were often used as floating gun platforms expressly for this purpose. However, given the relatively primitive nature of the fire control computers and radar of the era combined with the high velocity of naval gunfire, accuracy was poor until troops landed and were able to radio back reports to the ship.
The solution was to engage in longer bombardment periods—up to two weeks, in some cases—saturating target areas with fire until a lucky few shells had destroyed the intended targets. This alerted an enemy that he was about to be attacked. In the Pacific War this mattered less, as the defenders were usually expecting their island strongholds to be invaded at some point and had already committed whatever combat resources were available. Bombardment periods were usually shorter in the European theatre, where surprise was more often valued, reinforcement far more likely, and ships' guns were responding to the movements of mobile defenders, not whittling away at static fortifications.
Naval gunfire could reach as far as 20 miles (32 km) inland, and was often used to supplement land-based artillery. The heavy-calibre guns of some eighteen battleships and cruisers were used to stop German Panzer counterattack at Salerno. Naval gunfire was used extensively throughout Normandy, although initially the surprise nature of the landings themselves precluded a drawn-out bombardment which could have reduced the Atlantic Wall defences sufficiently, a process that fell to specialist armoured vehicles instead.
Naval gunfire was also useful in a defensive capacity. Older ships were occasionally beached to provide a coastal defence platform, and during the Battle of France the British discovered effective anti-tank artillery in the form of the four-inch (102 mm) guns from destroyers tied up at the quays of Boulogne."
http://en.wikipedia.org/wiki/Naval_gunfire_support