• 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

jsp and java beans

 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why aren't you using the JSTL and EL? getProperty and setProperty are obsolete.
 
Bartender
Posts: 1845
10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic