3

In the servlet, I set session value

HttpSession session = httpRequest.getSession();
session.setAttribute("user", "adam");

Then, on the JSP page, when I try to get the value <c:out value="${user}"></c:out>, I got the error According to TLD or attribute directive in tag file, attribute value does not accept any expressions

Then how can I get the session variable?

Cacheing
  • 3,431
  • 20
  • 46
  • 65
  • possible duplicate of http://stackoverflow.com/questions/4889431/access-session-attribute-on-jstl – Michał Rybak Sep 27 '13 at 23:25
  • @MichałRybak I used the answer provided by this link, and it doesn't work – Cacheing Sep 27 '13 at 23:28
  • sorry, I was misguided by the title... what does your taglib import look like? – Michał Rybak Sep 27 '13 at 23:53
  • according to [this question](http://stackoverflow.com/questions/13428788/according-to-tld-or-attribute-directive-in-tag-file-attribute-items-does-not-ac) your issue can maybe be resolved by correcting taglib declaration, but without looking into your code I can't say anything ;) – Michał Rybak Sep 28 '13 at 00:02
  • 1
    @MichałRybak Then I got this error `The absolute uri: http://java.sun.com/jsp/jstl/core cannot be resolved in either web.xml or the jar files deployed with this application` even though I used `jstl-1.2.jar` – Cacheing Sep 28 '13 at 00:12
  • @MichałRybak according to this http://stackoverflow.com/questions/8701307/the-absolute-uri-http-java-sun-com-jsp-jstl-core-cannot-be-resolved-in-either – Cacheing Sep 28 '13 at 00:12
  • please attach your configuration files. – Michał Rybak Sep 28 '13 at 00:48

1 Answers1

5

On your JSP page use -

Username : ${sessionScope.user}
Maverick
  • 302
  • 1
  • 5
  • 17