Archimedes and Wallis
Surely the directed energy travels at the speed of light, so you can't detect it until it hits you and then it's too late to do anything about it.
A modern warship is quite a large target, so when part of it is under attack from a directed energy weapon there would be a lot of ship left to respond. Conversely, in Ancient Greece, when Syracuse was besieged by the Romans, Archimedes designed weapons which incinerated enemy galleys using sunlight:
"The 2nd century AD author Lucian wrote that during the Siege of Syracuse, Archimedes destroyed enemy ships with fire. Around 500 AD, Anthemius of Tralles mentions burning-glasses as Archimedes' weapon. The device was used to focus sunlight onto approaching ships, causing them to catch fire."*
In WW2 thin strips of aluminium foil were used to deceive German radar during the invasion of Normandy.
"Sitting behind Perspex at the Boscombe Down Aviation Collection, the tangled strips of aluminium tape, called Chaff, helped to disrupt German radars. When dropped at the right point over the Channel, the tape would be picked up on radar and fooled the Germans into believing an invasion was happening. The method was invented by Barnes Wallis, who also famously developed the "bouncing bomb" for the Dambusters raids."**
* From: https://en.wikipedia.org/wiki/Archimedes%27_heat_ray#:~:text=The%202nd%20century%20AD%20author,causing%20them%20to%20catch%20fire.
** https://www.bbc.co.uk/news/articles/ckvv3zek21po#:~:text=Sitting%20behind%20Perspex%20at%20the,believing%20an%20invasion%20was%20happening.