• 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 ...
  • Campbell Ritchie
  • Devaka Cooray
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
  • paul wheaton
  • Jeanne Boyarsky
  • Tim Cooke
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Mikalai Zaikin
  • Carey Brown

Attempted a bean operation on a null object.

Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all, I am a new to web and struts programming and just starting to learn how to program in struts by making some simple WEB programs taken from the tutorials I had gotten from the web.

I have a JSP that displays the list of users and in the last column of each row, theres an html link that allows it to View, Edit or Delete each row. Here's my JSP.

<%@ taglib uri="/WEB-INF/taglibs/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/taglibs/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/taglibs/struts-logic.tld" prefix="logic" %>

<base href="<%=basePath%>">

<bean:message key="apex.title"/>
<bean:message key="apex.user.title"/>

<script type="text/javascript">
function showRow(r)
var i=r.parentNode.rowIndex
var x=document.getElementById('tblUser').rows [i].cells
return (x[0].innerHTML)


<body bgcolor="lightblue">
<p><h1><bean:message key="apex.user.list"/></h1></p>

<table border="1" cellpadding="3" id="tblUser">
<tr bgcolor="CCCCFF">
<th width="100">
<bean:message key="apex.user.username"/>
<th width="150">
<bean:message key="apex.user.lastname"/>
<th width="150">
<bean:message key="apex.user.firstname"/>
<th width="150">
<bean:message key="apex.user.actions"/>
<logic:iterate id="user" name="users">
<tr align="center" bgcolor="FFFFFF">
<td bgcolor="FFFFCC">
<bean:write name="user" property="username"/>
<bean:write name="user" property="lastName"/>
<bean:write name="user" property="firstName"/>
<td bgcolor="FFFFCC">
<html:link property="uvwe" action="/viewUser.do">
<bean:message key="button.view"/>
<jsp:useBean id="personUserName" class="com.training.bdo.User" scope="request">
<jsp:setProperty name="personUserName" property="username" param="showRow(r)"/>
<html:link property="uedt" action="/editUser.do">
<bean:message key="button.edit"/>
<html:link property="udel" action="/deleteUser.do">
<bean:message key="button.delete"/>

<button property="uadd">
<bean:message key="apex.user.new"/>
<button property="main">
<bean:message key="apex.main.page"/>


What I want is that when I click the link like view user, it will forward me to the url = "/viewUser.do" defined in the struts-config.xml. This will just basically display complete user data. But before I could forward it I want to save the data of the username.

So what I have thought was to save it in a java bean using <jsp:usebean>. I use javascript so I could have a reference on the rows that I have click. I dont know if this is the right way of doing it

<jsp:useBean id="personUserName" class="com.training.bdo.User">
<jsp:setProperty name="personUserName" property="username" param="showRow(this)"/>

The jsp that I want to forward this just basically displays the username

<base href="<%=basePath%>">

<title>My JSP 'viewUserProfile.jsp' starting page</title>


<h1>This page will show user data. </h1><br>

Your user Name is: ${personUserName.username}
<!--Other data to follow upon retrieval of the user name attribute-->

I am receiving an error: Attempted a bean operation on a null object.
Please pardon me if my question maybe too simple to others. I am just working this out on my own through web tutorials.
If you are using a wood chipper, you are doing it wrong. Even on this tiny ad:
a bit of art, as a gift, that will fit in a stocking
    Bookmark Topic Watch Topic
  • New Topic