0

I'm trying to setup a JSP that gets information from a Servlet. I feel that I'm doing something really stupid but in my servlet I am using:

HttpSession session = hreq.getSession();
hreq.setAttribute("results", "hreq value");
session.setAttribute("results","This is the value.");
hreq.getRequestDispatcher("jsp.jsp").forward(hreq, hres);

I can't seem to pick up either of the set values in my JSP. I've tried using:

<% out.print(session.getAttribute("results"));%>
<c:out value='${results}' />
${results}

None of them seems to be retriving the value.

What am I doing wrong, because it's driving me up the wall?

Han
  • 263
  • 1
  • 8
Lex Man
  • 135
  • 1
  • 12
  • 1
    Include full .jsp file. Include result - how does your .jsp look like. If I'll put these snippets only, it works fine and I can't reproduce it. Introduce [minimal reproducible example](https://stackoverflow.com/help/minimal-reproducible-example), please. – Giorgi Tsiklauri Feb 17 '21 at 16:09

1 Answers1

0

Make sure you import JSTL tags, as the first line, in your .jsp file:

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
Han
  • 263
  • 1
  • 8
Giorgi Tsiklauri
  • 9,715
  • 8
  • 45
  • 66