Two methods for obtaining the content of a child page from the parent page of two JSP pages
Requirement Description: Two JSP pages. The parent page requires the content of the Child page, but the child page is hidden. Specifically, the Child page is a series of templates, the parent page needs to obtain these templates by id and does not want to import them using the <include> method. If there are too many templates, the entire parent page will be too large and loading will be slow. The following two solutions, I wonder if this problem has been solved.
1. ajax
Implementation process: Send an ajax request to the sub-page. After the sub-page obtains the parameter id and interacts with the js variable using java, the required template information is returned.
Disadvantage: Converting js variables to java variables is troublesome. You need to use form forms for submission. Besides, java scripts in jsp run on the server and require resource overhead on the server, and increases interactions.
2. Introduction through iframe
Implementation process: Use iframe to introduce the sub-page, and then get the required template through $ (iframe. contents (). find ("#" + id) [0]). val.
Disadvantage: I'm not sure if iframe can be delayed for loading. If I want to import the entire page like <include>, this method is not OK.