Skip to main content
added 601 characters in body
Source Link
Goran Jovic
  • 2.8k
  • 25
  • 28

why do programmers weight JSP over servlets for that?

You can look at JSP as just another more friendly syntax for writing servlets. So, it's not so much a choice between JSP and servlets: the choice is between writing servlets in JSP syntax and writing them in raw Java. As to why would someone prefer the first over the latter, for many (not all) situations raw Java syntax is very inconvenient since:

  • entire page is inside the out.println() calls

  • usually means lots of markup within strings

  • for non trivial pages this is insanely difficult to read not to mention debug

  • the increased development cost is much much greater than the lowered performance cost (which isn't lowered at all, see the next point)

If servlet is used then a lot of computation work can be saved.

No, not really. Well, only computation at deploy time, when servlets are generated from the JSPs, but during run time it's the same (assuming you disable the option to generate servlets in every request).

why do programmers weight JSP over servlets for that?

You can look at JSP as just another more friendly syntax for writing servlets.

If servlet is used then a lot of computation work can be saved.

No, not really. Well, only computation at deploy time, when servlets are generated from the JSPs, but during run time it's the same (assuming you disable the option to generate servlets in every request).

why do programmers weight JSP over servlets for that?

You can look at JSP as just another more friendly syntax for writing servlets. So, it's not so much a choice between JSP and servlets: the choice is between writing servlets in JSP syntax and writing them in raw Java. As to why would someone prefer the first over the latter, for many (not all) situations raw Java syntax is very inconvenient since:

  • entire page is inside the out.println() calls

  • usually means lots of markup within strings

  • for non trivial pages this is insanely difficult to read not to mention debug

  • the increased development cost is much much greater than the lowered performance cost (which isn't lowered at all, see the next point)

If servlet is used then a lot of computation work can be saved.

No, not really. Well, only computation at deploy time, when servlets are generated from the JSPs, but during run time it's the same (assuming you disable the option to generate servlets in every request).

Source Link
Goran Jovic
  • 2.8k
  • 25
  • 28

why do programmers weight JSP over servlets for that?

You can look at JSP as just another more friendly syntax for writing servlets.

If servlet is used then a lot of computation work can be saved.

No, not really. Well, only computation at deploy time, when servlets are generated from the JSPs, but during run time it's the same (assuming you disable the option to generate servlets in every request).