aspose file tools*
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
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: 61769
    
  67

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: 1029
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: 61769
    
  67

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
 
wood burning stoves
 
subject: jsp and java beans