0

As html pages are executed in the host(here browser is the host),

  1. how the JSP code is executed?
  2. Why users are not able to see the JSP code/logic by right clicking the html page and clicking Inspect html elements?
  3. If JSP belongs to java family, how is it getting executed in browser?
Vinoth Krishnan
  • 2,925
  • 6
  • 29
  • 34

2 Answers2

1

how the JSP code is executed?

Java Server Pages are executed by a Java engine running on the server (e.g. Apache Tomcat). Their output (usually HTML) is sent to the client.

Why users are not able to see the JSP code/logic by right clicking the html page and clicking Inspect html elements?

Because it is never sent to the client, only its output is.

If JSP belongs to java family, how is it getting executed in browser?

It isn't (although some browsers do still support Java Applets, but that's a more or less dead technology that worked in a completely different way to JSP).

Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335
0

FYI, it is not just executed by browser. You need Web/Application Server inorder to do that. For example Tomcat server. See the web server role from Oracle.

1. How the JSP code is executed?

The web server recognizes that the HTTP request is for a JSP page and forwards it to a JSP engine. This is done by using the URL or JSP page which ends with .jsp instead of .html.

2. Why users are not able to see the JSP code/logic by right clicking the html page and clicking Inspect html elements?

The JSP container moves the scriptlet(<% %>) content into the _jspService() method which is available to the server during processing of the request. For each client’s request the _jspService() method gets invoked, hence the code inside it executes for every request made by client. It will give only the resultant text/string.

3. If JSP belongs to java family, how is it getting executed in browser?

From BalusC response,

On a JSP request, the servlet container will execute the compiled JSP class and send the generated output (usually just HTML/CSS/JS) through the webserver over network to the client side, which in turn displays it in the web browser.

Community
  • 1
  • 1
Vinoth Krishnan
  • 2,925
  • 6
  • 29
  • 34
  • Wow. Thanks for explaining stuff. I have two questions now. 1) How much time you took to learn all these or to reach this level of expertise? 2) What were your methods of learning? 3) Could you answer this http://stackoverflow.com/questions/35833492/why-is-the-following-spring-project-throws-no-error-server-startsup-but-no-res –  Mar 06 '16 at 22:40
  • You are welcome..! I have been in J2EE development for last 4-5 years. Interested in learning new technologies and helping people to solve their issue through [StackOverflow](http://stackoverflow.com/users/1517735/vinoth-krishnan). I am learning most of stuff from tutorials and SO. I will check your question, [Accept](http://stackoverflow.com/help/accepted-answer) as a answer would be most useful to other users too. – Vinoth Krishnan Mar 07 '16 at 06:07