A friendly place for programming greenhorns!
Big Moose Saloon
Search
|
Java FAQ
|
Recent Topics
Register / Login
JavaRanch
»
Java Forums
»
Java
»
JSP
Author
Problem using Expression language in JSP page (java code)
Akmal Bajwa
Greenhorn
Joined: Jul 18, 2011
Posts: 3
posted
Jul 18, 2011 02:04:06
0
hi
i am in great trouble. problem is i create a
Servlet
and code is
HttpSession
session = request.getSession();
session.setAttribute("employee", employee);
"employee" is bean and now i am access that in jsp page like this:
<LI><B>First Name:</B> ${employee.name.firstName}
it work fine but if i use this bean in
java
code, it return null value like this:
<LI><B>First Name:</B> <%= pageContext.getAttribute("employee.name.firstName") %>
my requirement is that i have to use it in java code not simple html second one thing more if i do this code in Servlet:
session.setAttribute("attribute2", "USA");
and use this code in jsp:
<LI><B>attribute1:</B> <%= pageContext.findAttribute("attribute2") %>
so this code work fine but problem with bean so kindly help me. my need is get expression value in variable in java code in jsp
thanks,
Akmal
Ashwin Sridhar
Ranch Hand
Joined: Jul 09, 2011
Posts: 272
I like...
posted
Jul 18, 2011 05:38:00
0
<LI><B>First Name:</B> <%= pageContext.getAttribute("employee.name.firstName") %>
this would search for attribute in pageContext for name "employee.name.firstName".
Try using <jsp:getProperty> method or use Expression Language for same
Ashwin Sridhar
SCJP | SCWCD | OCA
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56229
13
I like...
posted
Jul 18, 2011 08:53:27
0
You should no longer be using scriptlets and scriptlet expressions. They have been discredited for almost 10 years now.
Use the JSTL and EL instead.
[
Smart Questions
] [
JSP FAQ
] [
Books by Bear
] [
Bear's FrontMan
] [
About Bear
]
I agree. Here's the link:
http://zeroturnaround.com/jrebel
- it saves me about five hours per week
subject: Problem using Expression language in JSP page (java code)
Similar Threads
html:select with two List
using jsp:useBean tag
El doubt
setting / accessgin Java Bean between page and servlet.
Accessing scoped variables using EL
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter