Two methods for obtaining the content of a child page from the parent page of two JSP pages

Source: Internet
Author: User

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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.