I am making a simple crud
in java using jsp
and servlets
.
And I came across the following situation:
I have layout.jsp
which makes the include of another dynamic page, which in this case will be excluir.jsp
. The page title is set within excluir.jsp
so the layout.jsp
page does not see the value of my title
variable.
I ask: how can layout.jsp
get the value of title
.
Note: I'm trying hard not to put this information in servlet
. Yes I know that if this variable is set to servlet
the layout .jsp
can get the value.
layout.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/xml" prefix="x" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<!doctype html>
<html lang="pt-BR">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title><c:out value="${title}" /></title>
<link href="/css/bootstrap.min.css" rel="stylesheet" />
<link href="/css/theme.css" rel="stylesheet" />
</head>
<body>
<c:import url="menu.jsp" />
<div class="container">
<c:import url = "${page}" />
</div>
<script src="/js/jquery.min.js"></script>
<script src="/js/bootstrap.min.js"></script>
</body>
</html>
delete.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %>
<c:set var="title" scope="request" value="Excluir página"/>
<h1><c:out value="${title}" /></h1>