Actually the question in the subject. Below is the Servlet and JSP code.
Servlet
import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @WebServlet("/") public class TestServlet extends HttpServlet { private static final long serialVersionUID = 1L; public TestServlet() { super(); } protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { request.setAttribute("name", "test"); getServletContext().getRequestDispatcher("index.jsp").forward(request, response); } } Jsp
<?xml version="1.0" encoding="ISO-8859-1" ?> <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /> <title>http</title> </head> <body> <% String name = (String) request.getAttribute("name"); %> <h1> Hello <%out.print(name); %> </h1> </body> </html>
String name = (String) request.getAttribute("name");and just<h1> Hello ${name} </h1>not tried? - Saidolim