After learning Servlets, I jumped straight to JSPs. One thing I learnt from Servlets is that whether request is GET or POST, Container would run either Servlet's doGet() or doPost() method. Technically, they are invoked by Servlet's service() method.
Then I came to JSP and saw jsp_Service() that executes entire JSP's code. Why is that? Meaning why are they behaving differently from that aspect?
To sum, if I said everything correctly, why does Container run Servlet's doGet() or doPost(), while it runs everything from JSP?
I'm not sure I understand the question. The container runs ALL the code it needs to run, regardless of whether it is a servlet or a JSP. Some of it is the developer's code, some is code the JSP engine added, and some is code that's part of the container. Given that servlets and JSPs take different approaches to executable content, it should be no surprise that they work differently.
jsp_Service() ... executes entire JSP's code.
No - there are also the jspInit() and jspDestroy() methods (and some scaffolding) which can actually be overwritten, although that'd be bad design.
JSP's are primarily intended as View Templates (if you're using the Model/View/Controller paradigm). Or, in other words, they should be mostly HTML with just enough dynamic content to do what's necessary.
They're designed to operate as linear code and they don't usually concern themselves with whether they were invoked by a GET, a POST, or something else. If your main purpose in life is to render the values found in JavaBeans in an aesthetically-pleasing setting, it doesn't matter,
More to the point. If you're worried about internal operations of JSPs you're almost certainly trying to do something that would better be done via an actual servlet.
It's a common mistake made by novices to do lots of work in JSPs using scriptlets. Scriplets these days are pretty useless, since JSTL can handle the simple stuff and the complex stuff is :censored: to debug. And to edit, since smart text editors have to switch between JSP/HTML editing mode and Java mode every time you move the cursor in and out of a scriptlet.
Plus if you use scriptlets, Bear will growl at you.
Loudly announcing something is true and finding out you're wrong makes you feel foolish.
Finding out you're wrong and refusing to admit it makes you LOOK foolish.