How do I add a servlet to replace scriptlets in a JSP?

This question already has an answer here:

  • How to avoid Java code in JSP files? 28 answers

  • If i understood the scenario completely,

    Steps:

  • You could send the control to the Servlet instead of the jsp directly. ie you will have to change the url slightly to point to Servlet not to the jsp.

  • Let the Servlet pre-process the request parameters (and some business logic if required)

  • The Servlet then forwards the request to the jsp which finally renders the view.

  • That should work, as the only change to the existing application is a slight url change.

    Caution: Hoping you have tests which test this part of the application !

    链接地址: http://www.djcxy.com/p/76602.html

    上一篇: 如何将Java代码从NetBeans中的jsp页面分离出来?

    下一篇: 如何添加一个servlet来替换JSP中的scriptlet?