I am reading a String value from database and printing it onto a jsp page through a servlet. The Problem is that on the Jsp the String 'null' is getting printed in case the field in the database is null. I need to have a blank editbox instead if the value in the database is null.
My database Access Object:
public String getVerEmpId(retailcustomervergobean rcvb) {
String var = "";
custid = rcvb.getCustid();
Connection conn;
try {
conn = db.getDbConnection();
String sql = "select CUST_EMP_ID from retail_cif_master where cust_id = ?";
PreparedStatement ps = conn.prepareStatement(sql);
ps.setString(1, custid.toUpperCase());
ResultSet rs = ps.executeQuery();
while (rs.next()) {
var = rs.getString("CUST_EMP_ID");
}
} catch (Exception asd) {
System.out.println(asd.getMessage());
}
return var;
}
My Servlet:
String custempid = rcvd.getVerEmpId(rcvb);
request.setAttribute("custempid", custempid);
My Jsp:
name="custEmpId" readonly="true" value="<%=request.getAttribute("custempid")%>"
My Display if the field is null:
My database is Oracle 11g and Browser is FireFox.