Tolkien has specifically stated that the Dead Marshes were inspired by the appearance of Northern France after the battle of the Somme. And that Sam is a reflection of the privates and batman he served with. That said, he explicitly denies that WW1 or WW2 had any influence on the actual plot.
I don't know how much you want to take the Tolkien's word for it (death of the author and all that) but there it is.
I don't know how much you want to take the Tolkien's word for it (death of the author and all that) but there it is.