• 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

Cannot find bean: "employeeObj" in scope: "request"

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can someone help?

ERROR:

javax.servlet.jsp.JspException: Cannot find bean: "employeeObj" in scope: "request"
at org.apache.struts.taglib.TagUtils.lookup(TagUtils.java:866)
at org.apache.struts.taglib.bean.DefineTag.doEndTag(DefineTag.java:219)
at org.apache.jsp.jsp.Success_jsp._jspService(Success_jsp.java:93)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:770)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:369)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:322)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:249)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:770)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:638)
at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:444)
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:382)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:310)
at org.apache.struts.chain.commands.servlet.PerformForward.handleAsForward(PerformForward.java:113)
at org.apache.struts.chain.commands.servlet.PerformForward.perform(PerformForward.java:96)
at org.apache.struts.chain.commands.AbstractPerformForward.execute(AbstractPerformForward.java:54)
at org.apache.struts.chain.commands.ActionCommandBase.execute(ActionCommandBase.java:51)
at org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:190)
at org.apache.commons.chain.generic.LookupCommand.execute(LookupCommand.java:304)
at org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:190)
at org.apache.struts.chain.ComposableRequestProcessor.process(ComposableRequestProcessor.java:283)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913)
at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:449)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:668)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:770)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:235)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:190)
at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:92)
at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.process(SecurityContextEstablishmentValve.java:126)
at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:70)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:330)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:829)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:598)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Unknown Source)


Here are the config and action files i amusing:





EmployeeDaoImpl




Struts-config




springcontext1.xml




Employeesearch1.jsp











 
vikas dembla
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please help!
 
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

vikas dembla wrote:Please help!



PatienceIsAVirtue: We are all volunteers answering questions in our spare time.
Are you aware that Struts 1 is past end of life and will not be updated? Do not use it unless absolutely necessary.
I don't see employeeObj referenced in your JSP. Does the problem occur when you load Employeesearch1.jsp or when you click the search button on that page?
 
vikas dembla
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I see error when I click on search button.
 
Joe Ess
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If I read your code correctly, there's another JSP page involved here. The search button triggers a call to /Emp/getMessage.do which, if successful, returns /jsp/Success.jsp. Why didn't you show this JSP?
Are you trying to adapt some working code to do a new task?
 
vikas dembla
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


Success.jsp is just populating the fields, if search is successful



Success.jsp





Here are the another files

EmployeeDetailsObj


public class EmployeeDetailsObj {
private int emp_id;
private int badgeNo;
private String firstName;
private String lastName;
private String hireDate;
private int SSN;
private String termDate;
private String email;
private String phoneNo;
private int addressid;
private String addr1;
private String addr2;
private String aptmtno;
private String city;
private String county;
private String state;
private int zip;
private String country;
private String costcode;
private String costcenter;
private String department;
private String section;
private String shift;
private String product;




And complete EmployeeDaoaiml.java

package com.subaru.hr.daoimpl;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import javax.sql.DataSource;

import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.jdbc.core.simple.ParameterizedRowMapper;

import com.subaru.hr.beans.EmployeeDetailsObj;

public class EmployeeDaoImpl {
private JdbcTemplate jdbcTemplate;
private DataSource dataSource;

public void setDataSource(DataSource dataSource) {
System.out.println("dataSource" + dataSource);
this.dataSource = dataSource;
this.jdbcTemplate = new JdbcTemplate(dataSource);
}

public DataSource getDataSource() {
return dataSource;
}

/*
* public JdbcTemplate getJdbcTemplate() { return jdbcTemplate; } public
* void setJdbcTemplate(JdbcTemplate jdbcTemplate) { this.jdbcTemplate =
* jdbcTemplate; }
*/

public boolean isEmployeeExists(int badgeNo) {
try {
int number = jdbcTemplate.queryForInt(
"select count(*) from Employee where BADGE_NO=?", badgeNo);

if (number > 0) {
System.out.println("Record Count" + number);
return true;
}
} catch (Exception exception) {
exception.printStackTrace();
}
return false;
}

public EmployeeDetailsObj getEmployeeDetails(int badgeNo) {
String qry = "select * from Employee where BADGE_NO=?";

EmployeeDetailsObj employeeObj = jdbcTemplate.queryForObject(qry,
new Object[] { badgeNo }, new RowMapper<EmployeeDetailsObj>() {
public EmployeeDetailsObj mapRow(ResultSet rs, int rowNum)
throws SQLException {
EmployeeDetailsObj employeeObj = new EmployeeDetailsObj();
employeeObj.setBadgeNo(rs.getInt("badge_no"));
employeeObj.setFirstName(rs.getString("first_name"));
employeeObj.setLastName(rs.getString("last_name"));
employeeObj.setHireDate(rs.getString("hire_Date"));
employeeObj.setTermDate(rs.getString("term_Date"));
employeeObj.setSSN(rs.getInt("ssn"));
employeeObj.setEmail(rs.getString("email"));
employeeObj.setPhoneNo(rs.getString("phone_no"));

/*
* employeeObj.setAddr1(rs.getString("addr1"));
* employeeObj.setAddr2(rs.getString("addr2"));
* employeeObj.setAptmtno(rs.getString("aptmtno"));
* employeeObj.setCity(rs.getString("city"));
* employeeObj.setCounty(rs.getString("county"));
* employeeObj.setState(rs.getString("state"));
* employeeObj.setZip(rs.getInt("zip"));
* employeeObj.setCountry(rs.getString("country"));
*/

return employeeObj;
}
});
return employeeObj;
}






public EmployeeDetailsObj search(String searchBy, String searchId)throws Exception {

System.out.println("searchBy " + searchBy + " searchId " + searchId);
//String qry = "select * from Employee";
String qry = "select * from Employee as e join empcostcode as ecc on e.Badge_no=ecc.Badge_No join costcode as cc on ecc.costcode_id=cc.id join department as d on cc.department_id = d.id join section as sec on cc.section_id=sec.id join costcenter as cocent on cc.costcenter_id=cocent.id";
if (searchBy != null) {
if (searchBy.equals("SSN"))
qry = qry + " where e.SSN=?";
else if (searchBy.equals("badgeNo"))
qry = qry + " where e.BADGE_NO=?";
}
System.out.println("qry " + qry);
EmployeeDetailsObj employeeObj = jdbcTemplate.queryForObject(qry,
new Object[] { searchId }, new RowMapper<EmployeeDetailsObj>() {
public EmployeeDetailsObj mapRow(ResultSet rs, int rowNum)
throws SQLException {
EmployeeDetailsObj employeeObj = new EmployeeDetailsObj();
employeeObj.setBadgeNo(rs.getInt("badge_no"));
employeeObj.setFirstName(rs.getString("first_name"));
employeeObj.setLastName(rs.getString("last_name"));
employeeObj.setHireDate(rs.getString("hire_Date"));
employeeObj.setTermDate(rs.getString("term_Date"));
employeeObj.setSSN(rs.getInt("ssn"));
employeeObj.setEmail(rs.getString("email"));
employeeObj.setPhoneNo(rs.getString("phone_no"));
//employeeObj.setDepartment(rs.getString("Department"));

/*
* employeeObj.setAddr1(rs.getString("addr1"));
* employeeObj.setAddr2(rs.getString("addr2"));
* employeeObj.setAptmtno(rs.getString("aptmtno"));
* employeeObj.setCity(rs.getString("city"));
* employeeObj.setCounty(rs.getString("county"));
* employeeObj.setState(rs.getString("state"));
* employeeObj.setZip(rs.getInt("zip"));
* employeeObj.setCountry(rs.getString("country"));
*/






return employeeObj;
}
});
return employeeObj;

}


public List<EmployeeDetailsObj> autoComplete(final String searchBy, String searchId)throws Exception {
searchId = searchId+"%";
System.out.println("searchBy " + searchBy + " searchId " + searchId);
String qry = "select * from Employee";
//String qry = "select * from Employee as e join empcostcode as ecc on e.Badge_no=ecc.Badge_No join costcode as cc on ecc.costcode_id=cc.id join department as d on cc.department_id = d.id join section as sec on cc.section_id=sec.id join costcenter as cocent on cc.costcenter_id=cocent.id";
if (searchBy != null) {
if (searchBy.equals("SSN"))
qry = qry + " where e.SSN like ?";
else if (searchBy.equals("badgeNo"))
qry = qry + " where e.BADGE_NO like ?";
}
System.out.println("qry " + qry);
return jdbcTemplate.query(qry,
new ParameterizedRowMapper<EmployeeDetailsObj>() {
public EmployeeDetailsObj mapRow(ResultSet rs, int rowNum)
throws SQLException {
EmployeeDetailsObj employeeObj = new EmployeeDetailsObj();
if (searchBy.equals("badgeNo"))
employeeObj.setBadgeNo(rs.getInt("badge_no"));
//employeeObj.setFirstName(rs.getString("first_name"));
//employeeObj.setLastName(rs.getString("last_name"));
if (searchBy.equals("SSN"))
employeeObj.setSSN(rs.getInt("ssn"));
return employeeObj;
}
},searchId);

}







}



 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic