Pratheeswaran.R
Pratheeswaran.R

Reputation: 904

How to include a Runtime file for @include in JSP

To include another file in JSP, we use the @include tag

<%@ include file="NameOfFile"%>

In my case i want to include a html file whose name will known during the run-time - i,e from Database.

How can I do this in JSP?

Upvotes: 3

Views: 5202

Answers (2)

Jaymelson Galang
Jaymelson Galang

Reputation: 401

You can use Include Directives

<%@include file="<%=FileName%>"%>

or JSP Include Action

<jsp:include page="<%=FileName%>"/>

the different is include directive includes a file during the translation phase.

while JSP Include Action includes a file at the time the page is requested

I recommend Spring MVC Framework as your controller to manipulate things. use url pattern instead of parameter.

example:

www.yourwebsite.com/products

instead of

www.yourwebsite.com/?p=products

Watch this video Spring MVC Framework

Upvotes: 0

Vinze
Vinze

Reputation: 2539

simply using jsp:include :

<jsp:include page="<%= htmlFileName %>" />

It works in my project where the file is stored in session to reload correctly the part updated with ajax

Upvotes: 6

Related Questions