Should I use TCP or UDP to run a web server

Solution 1:

Web servers work with the HTTP (and HTTPS) protocol which is TCP based.

As a general rule, if people neglect to specify whether they mean TCP/UDP/SomethingElse then they probably mean TCP.

Solution 2:

TCP establishes a connection and UPD just sends packets.

You will have packet loss with UDP. Sites like youtube.com use UDP for video streaming because it doesn't matter if you miss a few frames. youtube.com uses UDP because it's faster than TCP because that connection isn't established and you probably wouldn't notice missing frames anyway.

You want to use TCP because you don't want packet loss.