Angularjs returnJson from database - angularjs

I want to return a JSON Object in a datatable. I've provided the static working code that I found in an example in my angularjs template.
Thanks for help.
controller.js
function datatablesCtrl($scope,DTOptionsBuilder){
$scope.persons = [
{
id: '1',
firstName: 'Monica',
lastName: 'Smith'
},
{
id: '2',
firstName: 'Sandra',
lastName: 'Jackson'
}
];
}
Utenti.jsp
<div class="wrapper wrapper-content animated fadeInRight" ng-controller="datatablesCtrl">
<div class="row">
<div class="col-lg-12">
<table datatable="ng" dt-options="dtOptions" class="table table-striped table-bordered table-hover dataTables-example">
<thead>
<tr>
<th>ID</th>
<th>FirstName</th>
<th>LastName</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="person in persons">
<td>{{ person.id }}</td>
<td>{{ person.user }}</td>
<td>{{ person.password }}</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
I need to populate the $scope.person with data into a database.
The table of database is "utenti" with column id,fistName,lastName.
These are my classes.. There is also a class Utenti with a simple getter & setter.
UtentiService.class
#Service("UtentiService")
public class UtentiService implements IUtentiService{
private EntityManager entityManager;
final static Logger logger = Logger.getRootLogger();
#PersistenceContext
public void setEntityManager(EntityManager entityManager) {
this.entityManager = entityManager;
}
public EntityManager getEntityManager() {
return entityManager;
}
#Transactional(readOnly = true)
public List<Utenti> getAll() {
Query queryFindAll = null;
try{
queryFindAll = entityManager.createNamedQuery("utenti.findAll");
}catch(Exception ex){
logger.error("Failed in method **getAll** of utentiService: ",ex);
}
return (List)queryFindAll.getResultList();
}
}
IUtentiService.class
public interface IUtentiService {
public List<Utenti> getAll(); //Restituisce una lista di tutti i siti
}
UtentiRest.class
#Path("/utenti")
#Component
#Scope("request")
public class UtentiRest {
#Autowired
IUtentiService nameUtentiService;
final static Logger logger = Logger.getRootLogger();
#GET
#Produces("application/json")
#Path("/getAll")
public JSONObject getAll() {
ExecutorService executorService = Executors.newFixedThreadPool(10);
JSONObject jsonSitiTotal = new JSONObject();
try {
List<Utenti> soluzioni = nameUtentiService.getAll();
Iterator<Utenti> iter = soluzioni.iterator();
JSONArray jsonArray = new JSONArray();
while (iter.hasNext()) {
Utenti ut = (Utenti) iter.next();
JSONObject jsonSiti2 = new JSONObject();
jsonSiti2.put("id", ut.getId());
jsonSiti2.put("user", ut.getUserName());
jsonSiti2.put("password", ut.getPassword());
jsonArray.put(jsonSiti2);
}
jsonSitiTotal.put("Siti",jsonArray);
} catch (JSONException ex) {
logger.info(Level.ERROR, ex);
throw new WebApplicationException(
Response.status(Response.Status.BAD_REQUEST)
.entity("JSON Exception " + ex.getMessage())
.build()
);
} catch (NullPointerException ex) {
logger.info(Level.ERROR, ex);
throw new WebApplicationException(
Response.status(Response.Status.NO_CONTENT)
.entity("No process find ")
.build()
);
} catch (IllegalArgumentException ex) {
logger.info(Level.ERROR, ex);
throw new WebApplicationException(
Response.status(Response.Status.NOT_ACCEPTABLE)
.entity("Couldn't process request with the provided argument: "
+ " (" + ex.getMessage() + ")")
.build()
);
}finally {
executorService.shutdown();
}
return jsonSitiTotal;
}
}

Related

TypeError: eleves.map is not a function React/Spring-boot cannot display #ManyToOne relation

I have 2 entities with a Many to One relationship that I want to display. However, when I save the data in the student entity while leaving the level entity at null I manage to display it without problem because the response is an object.
But when I associate a student with a level the answer then becomes an array [] and I cannot display with the map function since map cannot iterate over an array.
Please if anyone has any idea to help me.
×
TypeError: eleves.map is not a function
I put the capture of my code side front and back
Entity Eleve
#Entity
#Data #NoArgsConstructor #AllArgsConstructor #ToString
public class Eleve implements Serializable{
#Id #GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
//#NotBlank(message = "Ce champs est requis")
#Column(unique = true)
private String matriculeEleve;
#NotBlank(message = "Ce champs est requis")
private String nom;
#NotBlank(message = "Ce champs est requis")
private String prenom;
#NotBlank(message = "Ce champs est requis")
private String adresse;
#NotBlank(message = "Ce champs est requis")
private String contactPrimaire;
private String contactSecondaire;
#NotBlank(message = "Ce champs est requis")
private String nomParents;
#Enumerated(EnumType.STRING)
private Gender gender;
#JsonFormat(shape=Shape.STRING, pattern="yyyy-MM-dd")
#Temporal(TemporalType.DATE)
private Date dateNaissance;
#Column(name = "date_inscription")
#JsonFormat(shape=Shape.STRING, pattern="yyyy-MM-dd")
#Temporal(TemporalType.DATE)
private Date createdAt = new Date(System.currentTimeMillis());
private String statut;
private String photo;
#ManyToOne(fetch = FetchType.LAZY)
private Groupe groupe;
#ManyToOne(fetch = FetchType.LAZY)
private Niveau niveau;
public enum Gender { Masculin, Feminin }
Entite Niveau
#Entity
#Data #NoArgsConstructor #AllArgsConstructor
public class Niveau implements Serializable{
#Id #GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
#NotBlank(message = "Ce champ est requis")
private String code_classe;
private String libelle;
#OneToMany(mappedBy = "niveau")
private Collection<Eleve> eleves;
}
FrontEnd React
Action code
export const allEleves = () => async dispatch => {
const res = await axios.get("http://localhost:8080/api/eleve/all");
dispatch({
type: GET_ELEVES,
payload: res.data
});
}
Eleve Component
componentDidMount(){
this.props.allEleves()
}
render() {
const {eleves } = this.props.eleves
const listEleveComponent1 = eleves.length < 1 ? (<Info className="alert alert-info text-center" role="alert">Aucun eleve inscrit</Info>) :
eleves.map(eleve => (<ElevesItems key = {eleve.id} eleve={eleve} />
))
return (
<div className="table-responsive">
<table className="table table-striped table-bordered first">
<thead>
<tr>
<th></th>
<th>Matricule</th>
<th>Nom</th>
<th>Prenom</th>
<th>Genre</th>
<th>Date de naissance</th>
<th>Nom parents</th>
<th>Contact 1</th>
<th>Contact 2</th>
<th>Adresse</th>
<th>Niveau</th>
<th>Actions</th>
</tr>
</thead>
{listEleveComponent}
</table>
</div>
ElevesItems
<tbody>
<tr>
<td> <img src="" alt="" height="50%"/></td>
<td>{this.props.eleve.matriculeEleve}</td>
<td>{this.props.eleve.nom}</td>
<td>{this.props.eleve.prenom}</td>
<td>{this.props.eleve.gender}</td>
<td>{this.props.eleve.dateNaissance}</td>
<td>{this.props.eleve.nomParents}</td>
<td>{this.props.eleve.contactPrimaire}</td>
<td>{this.props.eleve.contactSecondaire}</td>
<td>{this.props.eleve.adresse}</td>
<td>{this.props.eleve.createdAt}</td>
<td >{this.props.eleve.niveau}</td>
<td>
<Link to={`/eleve-detail/${this.props.eleve.id}`} className="btn btn-light"><i class="fas fa-eye"></i></Link>
<button className="btn btn-danger" onClick={this.onDelete.bind(this, this.props.eleve.id)}><i class="fas fa-trash-alt"/></button>
</td>
</tr>
</tbody>
//I see a problem with de structured array at
````const {eleves } = this.props.eleves````
// to solve this u can either convert it into an object for an example
````
let p2 = ["Annie", "Becky"]
const p3 = {friend: p2}
let {friend} = p3;
friend.map(e=> e+1).forEach(k=> console.log(k))
````
// you can check if this.props.eleves this returns an array then create a new //object and add it to that

Photo registered in the database is repeated in my system when listing

I have 2 methods that take it out of a video to be able to list images from the database to my ssitea in a jsp, what happens is that my system lists the images of a single person and they are repeated, when it should be showing the photo of each
method to list
public ArrayList<CitaVO> listarCitas(String cliente_idCliente) {
CitaVO citVO = null;
conexion = this.obtenerConexion();
ArrayList<CitaVO> listaCitas = new ArrayList<>();
try {
sql = "SELECT * FROM vwcitasactivas WHERE cliente_idCliente=?";
puente = conexion.prepareStatement(sql);
puente.setString(1, cliente_idCliente);
mensajero = puente.executeQuery();
while (mensajero.next()) {
citVO = new CitaVO(mensajero.getString(1),
mensajero.getString(2), mensajero.getBinaryStream(3),
mensajero.getString(4), mensajero.getString(5),
mensajero.getString(6), mensajero.getString(7),
mensajero.getString(8), mensajero.getString(9),
mensajero.getString(10), mensajero.getString(11),
mensajero.getString(12),cliente_idCliente);
listaCitas.add(citVO);
}
} catch (Exception e) {
Logger.getLogger(ProAgendaDAO.class.getName()).log(Level.SEVERE, null, e);
}
return listaCitas;
}
method to list images
public void listarImg(String cliente_idCliente,HttpServletResponse response){
InputStream inputStream= null;
OutputStream outputStream=null;
BufferedInputStream bufferedInputStream=null;
BufferedOutputStream bufferedOutputStream=null;
response.setContentType("image/*");
try {
conexion = this.obtenerConexion();
sql = "SELECT * FROM vwcitasactivas WHERE cliente_idCliente=?";
outputStream=response.getOutputStream();
puente = conexion.prepareStatement(sql);
puente.setString(1, cliente_idCliente);
mensajero = puente.executeQuery();
if (mensajero.next()) {
inputStream=(mensajero.getBinaryStream(3));
}
bufferedInputStream=new BufferedInputStream(inputStream);
bufferedOutputStream=new BufferedOutputStream(outputStream);
int i=0;
while((i=bufferedInputStream.read())!=-1){
bufferedOutputStream.write(i);
}
} catch (SQLException e) {
Logger.getLogger(CitaDAO.class.getName()).log(Level.SEVERE, null, e);
} catch (IOException ex) {
Logger.getLogger(CitaDAO.class.getName()).log(Level.SEVERE, null, ex);
} finally {
try {
Conexion conexBd = new Conexion();
conexBd.cerrarConexion();
} catch (SQLException e) {
Logger.getLogger(CitaDAO.class.getName()).log(Level.SEVERE, null, e);
}
}
}
my jsp code
<%
<%
CitaVO citVO = new CitaVO();
CitaDAO citDAO = new CitaDAO();
ArrayList<CitaVO> listaCitas = citDAO.listarCitas(idCliente);
for (int i = 0; i < listaCitas.size(); i++) {
citVO = listaCitas.get(i);
%>
<tr>
<td>
<div class="round-img">
<img src="ImagenControlador?idCliente=<%=idCliente%>" alt="" width="50px" height="50px" >
</div>
</td>
<td><%=citVO.getUsuNombre()%> <%=citVO.getUsuApellido()%></td>
<td><%=citVO.getUsuCiudad()%></td>
<td><%=citVO.getCitFecha()%></td>
<td><%=citVO.getProDia()%></td>
<td><%=citVO.getCitDireccion()%></td>
<td><%=citVO.getCitHoraInicio()%></td>
<td><%=citVO.getCitHoraFin()%></td>
<td <%=citVO.getCitEstado()%>><span class="badge badge-primary">Activa</span></td>
<td style="text-align: center">
<span><i class="ti-eye color-default" style="font-size: 18px"></i> </span>
<span><i class="ti-pencil-alt color-success" style="font-size: 18px"></i></span>
<span><i class="ti-trash color-danger" style="font-size: 18px"></i> </span>
</td>
</tr>
<%}%
these are my two methods to list the information and images and my jsp code where I list everything and the next result is the following
As you can see, I list the same image when the last person should have a totally different photo, I don't know why this happens, I answer any questions in the comments

Displaying the result set of a Db view in asp.net core view

I am executing a stored procedure from my asp.net core app. The procedure executes a select statement from a db view. The db view inner joins 3 tables. When I execute the following code the result set comes as an int throwing an exception as the razor view expects List, I need to receive it as a list in order to pass it to the razor view and display the table. I would appreciate any help.
ViewModel:
public class ViewModel
{
public int TimeKey { get; set; }
public int FiscsalYear { get; set; }
public string LocationNum { get; set; }
public string Location { get; set; }
}
View:
#model List<FactWorkOrdersViewModel>
#{
ViewBag.Title = "Stored Procedure Test";
}
<div class="container">
<table class="table table-hover">
<thead>
<tr>
<th colspan="5"><h3>Stored Procedures results</h3></th>
</tr>
<tr>
<th>TimeKey</th>
<th>Fiscal Year</th>
<th>Location Number</th>
<th>Location</th>
</tr>
</thead>
<tbody>
#foreach (var item in Model)
{
<tr>
<td>
#item.TimeKey
</td>
<td>
#item.WorkOrderAltKey
</td>
<td>
#item.FiscsalYear
</td>
<td>
#item.LocationNum
</td>
<td>
#item.Location
</td>
</tr>
}
</tbody>
</table>
<div>
Controller:
public IActionResult SPTest(ReportViewModel model)
{
DbConnection connection = db.Database.GetDbConnection();
using (DbCommand cmd = connection.CreateCommand())
{
cmd.CommandText = "ExecuteReport";
cmd.CommandType = System.Data.CommandType.StoredProcedure;
cmd.Parameters.Add(new SqlParameter("#ReportId", model.ID));
if (connection.State.Equals(ConnectionState.Closed))
{
connection.Open();
}
var result = cmd.ExecuteScalar();
//var result = cmd.ExecuteNonQuery();
if (connection.State.Equals(ConnectionState.Open))
{
connection.Close();
}
return View(result);
}
This is a possible duplicate.
Please refer to What is the difference between ExecuteScalar, ExecuteReader and ExecuteNonQuery? for more information.
Short answer : You need ExecuteReader not ExecuteScalar.
ExecuteScalar returns first column's value of first row. ExecuteReader will return the list of rows which we can iterate through and display on your page.
I figured it out, thanks #Amogh
public IActionResult SPTest(ReportViewModel model)
{
List<ViewModel> viewModel = new List<ViewModel>();
using (SqlConnection conn = new SqlConnection("server=ServerName;database=DBName; user id=user_id; password=password; MultipleActiveResultSets=true"))
{
conn.Open();
SqlCommand cmd = new SqlCommand("ExecuteReport", conn)
{
CommandType = CommandType.StoredProcedure
};
cmd.Parameters.Add(new SqlParameter("#ReportId", model.ID));
using (SqlDataReader rdr = cmd.ExecuteReader())
{
while (rdr.Read())
{
foreach (var item in rdr)
{
ViewModel vm = new ViewModel
{
TimeKey = (int)rdr.GetValue(0),
FiscsalYear = (int)rdr.GetValue(2),
LocationNum = (string)rdr.GetValue(5),
Location = (string)rdr.GetValue(6)
};
viewModel.Add(vm);
}
}
}
}
return View(viewModel);
}

Store image into database using Struts2 and EJB

I have to store my image into database Oracle using EJB through Struts2. It persists data but when I add input file to JSP I have NullPointerException on this line:
byte[] buffer=new byte[(int)this.telethoraxImg.length()];
Below are some parts of my code:
PictureAction.java
public class PictureAction extends ActionSupport implements SessionAware{
private static final long serialVersionUID = 1L;
private static final Logger log = Logger.getLogger(MorphoRECAction.class);
private Map session ;
private ExamMorpho exMoR;
private Patient pat;
private HttpServletRequest request;
public void setServletRequest(HttpServletRequest request) {
this.request=request;
}
public ExamMorpho getExam(){
return exMoR;
}
public void setExam(ExamMorpho exMoR){
this.exMoR = exMoR;
}
public Patient getPat(){
return pat;
}
public void setPat(Patient pat){
this.pat = pat;
}
private Date dateExMorpho;
private String echoAbdo;
private String echoCard;
private String exGyneco;
private String exOphtalmo;
private String mamo;
private String telethoraxTxt;
private File telethoraxImg;
public String execute(){
log.info("Entrée dans la méthode execute() ");
System.out.println("creation examen");
ExamMorpho ex = new ExamMorpho();
System.out.println("fin création");
try{
Patient pt = (Patient)session.get("lepat");
InitialContext initialContext = new InitialContext();
ExMorphoRemote facade = (ExMorphoRemote) initialContext.lookup("PatProjet/ExMorphoBean/remote");
System.out.println("ID Patient RECUPERE /" + pt.getIdPat());
System.out.println("Debut conversion image");
byte[] buffer=new byte[(int)this.telethoraxImg.length()];
/*exMoR = new ExamMorpho(buffer, dateExMorpho, echoAbdo, echoCard, exGyneco, exOphtalmo, mamo, telethoraxTxt); */
System.out.println("Fin conversion image");
FileInputStream in=new FileInputStream(this.telethoraxImg);
in.read(buffer);
ex.setTelethoraxImg(buffer);
ex.setDateExMorpho(dateExMorpho);
ex.setEchoAbdo(echoAbdo);
ex.setEchoCard(echoCard);
ex.setExGyneco(exGyneco);
ex.setExOphtalmo(exOphtalmo);
ex.setMamo(mamo);
ex.setTelethoraxTxt(telethoraxTxt);
System.out.println("FIN AJOUT IMAAAGE");
exMoR = facade.AddExMorphoR(ex, pt);
System.out.println("FIN AJOUT MORPHOOS");
} catch(Exception e) {
e.printStackTrace();
}
return SUCCESS;
}
/*private byte[] telethoraxImg = null;
public byte[] getTelethoraxImg() {
return this.telethoraxImg;
}
public void setTelethoraxImg(byte[] telethoraxImg) {
System.out.println("ENTREE ADD IMAGE");
this.telethoraxImg = telethoraxImg;
System.out.println("SORTIE ADD IMAGE");
}*/
/*private Date dateExMorpho = null;
public Date getDateExMorpho() {
return this.dateExMorpho;
}
public void setDateExMorpho(Date dateExMorpho) {
this.dateExMorpho = dateExMorpho;
}
private String echoAbdo = null;
public String getEchoAbdo() {
return this.echoAbdo;
}
public void setEchoAbdo(String echoAbdo) {
this.echoAbdo = echoAbdo;
}
private String echoCard = null;
public String getEchoCard() {
return this.echoCard;
}
public void setEchoCard(String echoCard) {
this.echoCard = echoCard;
}
private String exGyneco = null;
public String getExGyneco() {
return this.exGyneco;
}
public void setExGyneco(String exGyneco) {
this.exGyneco = exGyneco;
}
private String exOphtalmo = null;
public String getExOphtalmo() {
return this.exOphtalmo;
}
public void setExOphtalmo(String exOphtalmo) {
this.exOphtalmo = exOphtalmo;
}
private String mamo = null;
public String getMamo() {
return this.mamo;
}
public void setMamo(String mamo) {
this.mamo = mamo;
}
private String telethoraxTxt = null;
public String getTelethoraxTxt() {
return this.telethoraxTxt;
}
public void setTelethoraxTxt(String telethoraxTxt) {
this.telethoraxTxt = telethoraxTxt;
}
*/
public void setSession(Map session) {
this.session = session;
}
public Map getSession() {
return session;
}
}
jsp code
<form action="fileUpload" method="POST" enctype ="multipart/form-data"><table>
<thead>
<tr>
<th colspan="2"></th>
<th colspan="2" rowspan="3"><center><input type="text" name="dateExMorpho" id="dn"/></a></center></th>
</tr>
</thead>
<tbody>
<tr>
</tr>
<tr><td colspan="2">Echographie Abdominale</td><td><textarea name="echoAbdo" rows=4 COLS=40></textarea></td></tr>
<tr><td colspan="2">Ecographie Cardiaque</td><td><textarea name="echoCard" rows=4 COLS=40></textarea></td></tr>
<tr><td colspan="2">Examen Gynécologique</td><td><textarea name="exGyneco" rows=4 COLS=40></textarea></td></tr>
<tr><td colspan="2">Examen Ophtalmoloique</td><td><textarea name="exOphtalmo" rows=4 COLS=40></textarea></td></tr>
<tr><td colspan="2">Mamographie</td><td><textarea name="mamo" rows=4 COLS=40></textarea></td></tr>
<tr>
<td ROWSPAN="2">Téléthorax</td>
<td >Image</td>
<td><s:file name="telethoraxImg" ContentEditable="false" style="float:left;"/></td>
</tr>
<tr>
<td>Remarques</td>
<td><textarea name="telethoraxTxt" rows=4 COLS=40></textarea></td>
</tr>
</tbody>
my Xml
<action name="fileUpload" class="clientStruts2.PictureAction">
<interceptor-ref name="fileUpload">
<param name="allowedTypes">
image/pjpeg,image/png,image/gif,image/jpeg,image/jpg,image/pjpeg</param>
<param name="maximumSize">2097152</param></interceptor-ref>
<interceptor-ref name="basicStack"/>
<result name="input">/login/dossierRec.jsp</result>
<result name="error">/login/dossierRec.jsp</result>
<result name="success">/login/dossierRec.jsp</result>
</action>

how to use jstl arraylist in jsp

I have problem to show data in jsp page with help of jstl. there is code and also error that i have got ;
my JSP PAGE is
<body>
<table border="1">
<thead>
<tr>
<th>UserId </th>
<th>First Name </th>
<th>Last Name </th>
<th>DOB </th>
<th>Email Id </th>
<th colspan="2" >Action</th>
</tr>
</thead>
<tbody>
<c:forEach items="${users}" var="user" >
<tr>
<td><c:out value="${user.userid}" /></td>
<td><c:out value="${user.firstName}" /></td>
<td><c:out value="${user.lastName}" /></td>
<td><fmt:formatDate pattern="yyyy-MMM-dd" value="${user.dob}" /></td>
<td><c:out value="${user.email}" /></td>
<td>Update</td>
<td>Delete</td>
</tr>
</c:forEach>
</tbody>
</table>
<p>Add User
this code where we fetch ALLUSERLIST IS :
public ArrayList getAllUsers()
{
ArrayList<User> USER = new ArrayList<User>();
try
{
iduQuery = "select * from user";
Statement st = conn.createStatement();
ResultSet rs =st.executeQuery(iduQuery);
while(rs.next())
{
User user =new User();
user.setUserid(rs.getString("userid"));
System.out.println("USER ID : " + user);
user.setFirstname(rs.getString("firstname"));
user.setLastname(rs.getString("lastname"));
user.setDob( new java.sql.Date(rs.getDate("dob").getTime()));
user.setEmail(rs.getString("email"));
USER.add(user);
}
}catch(Exception e)
{
e.printStackTrace();
System.out.println("Error : GetALLUSER " + e);
}
return USER;
}
Where we call jsp page :
forward ="/listUser.jsp";
ArrayList<User> myList = new ArrayList<User>();
myList = userdao.getAllUsers();
System.out.println("THis List of data arte : " + myList);
request.setAttribute("users", myList);
and error is show that:
HTTP Status 500 -
org.apache.jasper.JasperException: org.apache.jasper.JasperException: An exception occurred processing JSP page /listUser.jsp at line 33
30: <tbody>
31: <c:forEach items="${users}" var="user">
32: <tr>
33: <td><c:out value="${user.userid}" /></td>
34: <td><c:out value="${user.firstName}" /></td>
35: <td><c:out value="${user.lastName}" /></td>
36: <td><fmt:formatDate pattern="yyyy-MMM-dd" value="${user.dob}" /></td>
User.class
package com.d.model;
import java.util.Date;;
public class User {
private String userid;
private String firstName;
private String lastName;
private Date dob;
private String email;
public String getUserid() {
return userid;
}
public void setUserid(String userid) {
this.userid = userid;
}
/**
* #return the firstname
*/
public String getFirstname() {
return firstName;
}
/**
* #param firstname the firstname to set
*/
public void setFirstname(String firstName) {
this.firstName = firstName;
}
/**
* #return the dob
*/
public Date getDob() {
return dob;
}
/**
* #param dob the dob to set
*/
public void setDob(Date dob) {
this.dob = dob;
}
/**
* #return the email
*/
public String getEmail() {
return email;
}
/**
* #param email the email to set
*/
public void setEmail(String email) {
this.email = email;
}
/**
* #return the lastname
*/
public String getLastname() {
return lastName;
}
/**
* #param lastname the lastname to set
*/
public void setLastname(String lastName) {
this.lastName = lastName;
}
#Override
public String toString() {
return "User [userid= " + userid + ", firstName= '" + firstName
+ "', lastName=" + lastName + ", dob=" + dob + ", email="
+ email + "]";
}
}
spelling mistake setUsrid.change it setUserid
you are setting usrid but you are accessing userid
user.setUsrid(rs.getString("userid")); //usrid
${user.userid} // userid
spelling mistake setUsrid.change it to setUserid
you are setting usrid but you are accessing userid
user.setUsrid(rs.getString("userid")); //usrid
${user.userid} // userid

Resources