Meaningless Drivel is fun!*
The moose likes JSP and the fly likes jsp and java beans Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "jsp and java beans" Watch "jsp and java beans" New topic
Author

jsp and java beans

hari vallabh shukla
Greenhorn

Joined: Jan 31, 2013
Posts: 21
Below code give output NULL





<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Registration</title>
</head>
<body>


<jsp:useBean id="userBean" class="registration.UserBean" scope="session">
</jsp:useBean>

YOUR NAME :<jsp:getProperty name="userBean" property="name"/>



YOUR EMAIL:<jsp:getProperty name="userBean" property="email"/>




</body>
</html>


OUTPUT is below

YOUR NAME : NULL
YOUR EMAIL :NULL




but when i write same code in scriplet it give correct output
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60743
    
  65

Why aren't you using the JSTL and EL? getProperty and setProperty are obsolete.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Stefan Evans
Bartender

Joined: Jul 06, 2005
Posts: 1016
what "same" code do you write in scriptlet?
If its not giving the same result, it can't be the same :-)

hari vallabh shukla
Greenhorn

Joined: Jan 31, 2013
Posts: 21
Stefan Evans wrote:what "same" code do you write in scriptlet?
If its not giving the same result, it can't be the same :-)





<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Registration</title>
</head>
<body>
<% registration.UserBean userBean=(registration.UserBean)Session.getAttribute("userBeanString"); %>

YOUR NAME : <%= userBean.getName()%>


YOUR EMAIL:<%= userBean.getEmail()%>


</body>
</html>


OUTPUT IS BELOW

YOUR NAME : CORRECT NAME
YOUR EMAIL :CORRECT EMAIL
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60743
    
  65

The EL for <%= userBean.getName()%> would be ${userBeanString.name}.

The EL and JSTL have been around for about 12 years. Is it not time to start using them?
hari vallabh shukla
Greenhorn

Joined: Jan 31, 2013
Posts: 21
Bear Bibeault wrote:The EL for <%= userBean.getName()%> would be ${userBeanString.name}.

The EL and JSTL have been around for about 12 years. Is it not time to start using them?



Thanks iam using EL and it working fine
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: jsp and java beans
 
Similar Threads
jsp second request also make new object
retrive serialize files data ERROR
use of value object ( javabeans )
How to create scrolling text?
Help:jsp pass message to Beans, but always receive null