search

Home  >  Q&A  >  body text

javascript - Issues about embedding js code in jsp

This is a system built by my company. In it, we often see HTML code embedded in the if-else statement of jsp. I have not found this syntax in all the jsp and javascript books, and what I know The thing is that the jsp code will be compiled on the server side and the result will be sent to the browser, while html and js will be executed directly on the browser side. So what is the compilation or execution mechanism of code in this form?

PHP中文网PHP中文网2701 days ago872

reply all(2)I'll reply

  • 曾经蜡笔没有小新

    曾经蜡笔没有小新2017-07-05 11:06:08

    <%%>What is wrapped is the logical code part, and what is not wrapped is output directly.
    Like this

    <% if(one==1){%>
        <p>如果one是1,你就能看到我</p>
    <% }else {%>
        <p>你只看到我,说明one不是1咯</p>
    <% } %>

    For example, when the browser requests a certain jsp, the jsp renders the above code into html on the server side, and then returns it to the browser. I can’t understand the content of the <%%> part on the browser side.

    Perhaps the questioner can look for knowledge about "templates"?

    reply
    0
  • 巴扎黑

    巴扎黑2017-07-05 11:06:08

    It is recommended that you learn about servlets

    reply
    0
  • Cancelreply