Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within JSP
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Jeanne Boyarsky
Ron McLeod
Paul Clapham
Liutauras Vilda
Sheriffs:
paul wheaton
Rob Spoor
Devaka Cooray
Saloon Keepers:
Stephan van Hulst
Tim Holloway
Carey Brown
Frits Walraven
Tim Moores
Bartenders:
Mikalai Zaikin
Forum:
JSP
jsp:getProperty gives null
shawn peter
Ranch Hand
Posts: 1325
1
posted 14 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
I created bean class in my package.
package my; public class Mybean { private String name; private int age; private String address; public String getName() { return name; } public void setName(String name) { this.name = name; } public int getAge() { return age; } public void setAge(int age) { this.age = age; } public String getAddress() { return address; } public void setAddress(String address) { this.address = address; } }
how i set the values for bean class using
jsp
setproperty
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
I like...
posted 14 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
<jsp:useBean id="mybean" class="my.Mybean"> <jsp:setProperty name="mybean" property="name" value="aruna"/> <jsp:setProperty name="mybean" property="age" value="24"/> <jsp:setProperty name="mybean" property="address" value="bangalore,India"/> </jsp:useBean>
shawn peter
Ranch Hand
Posts: 1325
1
posted 14 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
but still it gives null
<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>Insert title here</title> </head> <body> <jsp:useBean id="mybean" class="my.Mybean"> <jsp:setProperty name="mybean" property="name" value="aruna"/> <jsp:setProperty name="mybean" property="age" value="24"/> <jsp:setProperty name="mybean" property="address" value="bangalore,India"/> </jsp:useBean> <jsp:useBean id="aruna" class="my.Mybean" scope="request"> <jsp:getProperty name="aruna" property="name"/> </jsp:useBean> </body> </html>
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
I like...
posted 14 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
the useBean instance is different . give the id attribute name as same name
shawn peter
Ranch Hand
Posts: 1325
1
posted 14 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
I change it as below.then it says " duplicate local variable name mybean "
<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>Insert title here</title> </head> <body> <jsp:useBean id="mybean" class="my.Mybean" scope="session"> <jsp:setProperty name="mybean" property="name" value="aruna"/> <jsp:setProperty name="mybean" property="age" value="24"/> <jsp:setProperty name="mybean" property="address" value="bangalore,India"/> </jsp:useBean> <jsp:useBean id="mybean" class="my.Mybean" scope="session"> <jsp:getProperty name="aruna" property="name"/> </jsp:useBean> </body> </html>
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
I like...
posted 14 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
<jsp:useBean id="mybean" class="my.Mybean" scope="session"> <jsp:getProperty name="aruna" property="name"/> </jsp:useBean>
if you want to get the value just use <jsp:getProperty name="mybean" property="name"/> . no need to create the same bean again.
it is like below.which will cause compile time error.
A a = new A(); A a = new A();
Did you see how Paul
cut 87% off of his electric heat bill with 82 watts of micro heaters
?
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
Exception in thread "main" org.springframework.beans.factory.BeanCreationException:
cannot find symbol
complex data type in axis 2 web service
request time expression
Error setting the expression with value [Ljava.lang.String;@1d05b0a
More...