I would like to include an jsp and (separate) response with it too.
include:
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<div><%@include file="content.jsp" %></div>
</body>
</html>
and this is content.jsp:
<p>${message}</p>
Message is a text from database. eg.: "Hello!"
Responses: url: /
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<div>Hello!</div>
</body>
</html>
url: /hello
<p>Hello!</p>
So my ask is how I recycle a jsp file if it is contain parameters?
So my ask is how I recycle a jsp file if it is contain parameters?
Using an efficient template system, fragmenting your jsp and create pages with single include.
Or you use
<% String message1 = request.getParameter("message"); %> <jsp:include page="...." > <jsp:param name="param1" value=<%=message1%> > </jsp:param> </jsp:include>
Or you can copy and paste and using controller to manage the parameters.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.