JSTL c:import Example

JSTL c:import Example explains about How to use c:import tag inside JSTL

Consider an example, where you need to include a content of a page using JSTL, In that case you can use JSTL c:import Tag

c:import Tag is available as a part of JSTL core tags, c:import Tag provides including of content from other sites to current page

Difference between c:import and jsp:include is that, By using c:import tag we can also provide absolute url such as "http://www.javatips.net". we can also utilize some additional attributes such as url, scope, charEncoding etc

You can see the below example demonstrating the usage JSTL c:import Example inside JSTL

Required Libraries

You need to download

  1. Tomcat 9
  2. JSTL 1.2

Following jar must be in classpath

  1. jstl-1.2.jar

JSTL c:import Example

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>

  <title>JSTL c:import Example</title>

  <!--JSTL c:import Example-->
	<c:import var="content" scope="request" url="http://www.javatips.net" />
	<c:out value="${content}" />

Here all the contents from www.javatips.net ( we are providing an absolute url here) are fetched and stored in request scope, which will be shown using c:out tag


Your email address will not be published. Required fields are marked *