0

I wish to use $(member.email), a variable which I've passed into a JSP page, inside of a <% block on that same page. Its value shows up outside of the block, but inside the block it can't see it at all.

I have tried using request.getAttribute("member.email") but that merely spit back a null. Request.getAttribute("member.email") gives me a string, which does not have the aforementioned value outside of the block.

I am unsure how to describe this problem any better than I have.

rodentry
  • 268
  • 3
  • 12

1 Answers1

1

This is how ${member.email} basically works "under the covers" (scope and null checks omitted):

Member member = (Member) request.getAttribute("member");
String email = member.getEmail();
out.print(email);

Please note that writing Java code in JSP files is considered a bad practice. If you intend to serve JSON, you can better write it from inside the servlet instead of a JSP file. JSP is more for HTML.

Community
  • 1
  • 1
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • Exactly what I needed, thank you. While I share your distaste, I'm afraid this one jsp file hasn't been complying too well with my servlet. I think I'll have to accept one bit of bad code over ten more hours of head aches. – rodentry Feb 12 '12 at 03:34