View items from database using JSP [on hold]
up vote
-1
down vote
favorite
I have a table called Developers
.
DeveloperName | password_ | Email
john 1234 john@gmail.com
Rose 5678 Rose@gmail.com
Developer Class
public class Developers {
private int developer_id;
private String developerName;
private String developerPassword;
private String Email;
public Developers(int developer_id, String developerName, String
developerPassword, String Email) {
this.developer_id = developer_id;
this.developerName = developerName;
this.developerPassword = developerPassword;
this.Email = Email;
}
public Developers(String developerName, String developerPassword, String Email) {
this.developerName = developerName;
this.developerPassword = developerPassword;
this.Email = Email;
}
public int getDeveloper_id() {
return developer_id;
}
public String getDeveloperName() {
return developerName;
}
public String getDeveloperPassword() {
return developerPassword;
}
public String getEmail() {
return Email;
}
public void setDeveloper_id(int developer_id) {
this.developer_id = developer_id;
}
public void setDeveloperName(String developerName) {
this.developerName = developerName;
}
public void setDeveloperPassword(String developerPassword) {
this.developerPassword = developerPassword;
}
public void setEmail(String Email) {
this.Email = Email;
}
}
And I have the dataAccess
class with method to view the records from the table.
public List<Developers> DeveloperList() throws SQLException{
ResultSet set;
String sql ="select DeveloperName , password_, Email from developers";
Connection conn;
conn = DbConnection.ConnectDb();
List<Developers> DeveloperList=new ArrayList();
PreparedStatement preparedstate = conn.prepareStatement(sql);
set = preparedstate.executeQuery();
while(set.next()){
String name = set.getString(1);
String password = set.getString(2);
String Email = set.getString(3);
Developers dev = new Developers(name,password,Email);
DeveloperList.add(dev);
}
return DeveloperList;
}
}
And Servlet as given below
public class DisplayDevelopers extends HttpServlet {
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse
response)
throws ServletException, IOException {
try {
DataAccess.DeveloperAccess DataAccess = new DataAccess.DeveloperAccess();
request.setAttribute("DisplayDevelopers", DataAccess.DeveloperList());
RequestDispatcher rd = request.getRequestDispatcher("Developers.jsp");
rd.forward(request, response);
processRequest(request, response);
} catch (SQLException ex) {
Logger.getLogger(DisplayDevelopers.class.getName()).log(Level.SEVERE, null, ex);
}
}
My jsp page as below
<% List<Developers> DisplayDevelopers = (List<Developers>) request.getAttribute("DisplayDevelopers");
pageContext.setAttribute("DisplayDevelopers", DisplayDevelopers); %>
<table>
<tr><th>Developer Name</th>
<th>Developer Password</th>
<th>Email</th>
</tr>
<c:forEach items="${DisplayDevelopers}" var="DisplayDevelopers">
<tr><td><c:out value="${DisplayDevelopers.developerName}"/></td>
<td><c:out value="${DisplayDevelopers.developerPassword}"/></td>
<td><c:out value="${DisplayDevelopers.Email}" /></td></tr>
</c:forEach>
</table>
The problem is it does not display data ? I am kind of new to Java web development am I doing something wrong here?
Any suggestions?
java servlets jsp
New contributor
put on hold as off-topic by mdfst13, πάντα ῥεῖ, Mathias Ettinger, Heslacher, Graipher 13 hours ago
This question appears to be off-topic. The users who voted to close gave this specific reason:
- "Code not implemented or not working as intended: Code Review is a community where programmers peer-review your working code to address issues such as security, maintainability, performance, and scalability. We require that the code be working correctly, to the best of the author's knowledge, before proceeding with a review." – mdfst13, πάντα ῥεῖ, Mathias Ettinger, Heslacher, Graipher
If this question can be reworded to fit the rules in the help center, please edit the question.
add a comment |
up vote
-1
down vote
favorite
I have a table called Developers
.
DeveloperName | password_ | Email
john 1234 john@gmail.com
Rose 5678 Rose@gmail.com
Developer Class
public class Developers {
private int developer_id;
private String developerName;
private String developerPassword;
private String Email;
public Developers(int developer_id, String developerName, String
developerPassword, String Email) {
this.developer_id = developer_id;
this.developerName = developerName;
this.developerPassword = developerPassword;
this.Email = Email;
}
public Developers(String developerName, String developerPassword, String Email) {
this.developerName = developerName;
this.developerPassword = developerPassword;
this.Email = Email;
}
public int getDeveloper_id() {
return developer_id;
}
public String getDeveloperName() {
return developerName;
}
public String getDeveloperPassword() {
return developerPassword;
}
public String getEmail() {
return Email;
}
public void setDeveloper_id(int developer_id) {
this.developer_id = developer_id;
}
public void setDeveloperName(String developerName) {
this.developerName = developerName;
}
public void setDeveloperPassword(String developerPassword) {
this.developerPassword = developerPassword;
}
public void setEmail(String Email) {
this.Email = Email;
}
}
And I have the dataAccess
class with method to view the records from the table.
public List<Developers> DeveloperList() throws SQLException{
ResultSet set;
String sql ="select DeveloperName , password_, Email from developers";
Connection conn;
conn = DbConnection.ConnectDb();
List<Developers> DeveloperList=new ArrayList();
PreparedStatement preparedstate = conn.prepareStatement(sql);
set = preparedstate.executeQuery();
while(set.next()){
String name = set.getString(1);
String password = set.getString(2);
String Email = set.getString(3);
Developers dev = new Developers(name,password,Email);
DeveloperList.add(dev);
}
return DeveloperList;
}
}
And Servlet as given below
public class DisplayDevelopers extends HttpServlet {
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse
response)
throws ServletException, IOException {
try {
DataAccess.DeveloperAccess DataAccess = new DataAccess.DeveloperAccess();
request.setAttribute("DisplayDevelopers", DataAccess.DeveloperList());
RequestDispatcher rd = request.getRequestDispatcher("Developers.jsp");
rd.forward(request, response);
processRequest(request, response);
} catch (SQLException ex) {
Logger.getLogger(DisplayDevelopers.class.getName()).log(Level.SEVERE, null, ex);
}
}
My jsp page as below
<% List<Developers> DisplayDevelopers = (List<Developers>) request.getAttribute("DisplayDevelopers");
pageContext.setAttribute("DisplayDevelopers", DisplayDevelopers); %>
<table>
<tr><th>Developer Name</th>
<th>Developer Password</th>
<th>Email</th>
</tr>
<c:forEach items="${DisplayDevelopers}" var="DisplayDevelopers">
<tr><td><c:out value="${DisplayDevelopers.developerName}"/></td>
<td><c:out value="${DisplayDevelopers.developerPassword}"/></td>
<td><c:out value="${DisplayDevelopers.Email}" /></td></tr>
</c:forEach>
</table>
The problem is it does not display data ? I am kind of new to Java web development am I doing something wrong here?
Any suggestions?
java servlets jsp
New contributor
put on hold as off-topic by mdfst13, πάντα ῥεῖ, Mathias Ettinger, Heslacher, Graipher 13 hours ago
This question appears to be off-topic. The users who voted to close gave this specific reason:
- "Code not implemented or not working as intended: Code Review is a community where programmers peer-review your working code to address issues such as security, maintainability, performance, and scalability. We require that the code be working correctly, to the best of the author's knowledge, before proceeding with a review." – mdfst13, πάντα ῥεῖ, Mathias Ettinger, Heslacher, Graipher
If this question can be reworded to fit the rules in the help center, please edit the question.
4
Non-working code is off-topic for this site. If you pare down your current code into a MCVE (the smallest amount of code that still shows the problem), it should be on-topic on Stack Overflow. However, you might find that it is a duplicate of an existing question there. Hint: I think thattaglib
might be required to useforEach
. Also, JSP in general has been deprecated in favor of JSF. You might be better off switching now.
– mdfst13
14 hours ago
(Try not to keep readers of your post scrolling down to find out what your question is.)
– greybeard
14 hours ago
add a comment |
up vote
-1
down vote
favorite
up vote
-1
down vote
favorite
I have a table called Developers
.
DeveloperName | password_ | Email
john 1234 john@gmail.com
Rose 5678 Rose@gmail.com
Developer Class
public class Developers {
private int developer_id;
private String developerName;
private String developerPassword;
private String Email;
public Developers(int developer_id, String developerName, String
developerPassword, String Email) {
this.developer_id = developer_id;
this.developerName = developerName;
this.developerPassword = developerPassword;
this.Email = Email;
}
public Developers(String developerName, String developerPassword, String Email) {
this.developerName = developerName;
this.developerPassword = developerPassword;
this.Email = Email;
}
public int getDeveloper_id() {
return developer_id;
}
public String getDeveloperName() {
return developerName;
}
public String getDeveloperPassword() {
return developerPassword;
}
public String getEmail() {
return Email;
}
public void setDeveloper_id(int developer_id) {
this.developer_id = developer_id;
}
public void setDeveloperName(String developerName) {
this.developerName = developerName;
}
public void setDeveloperPassword(String developerPassword) {
this.developerPassword = developerPassword;
}
public void setEmail(String Email) {
this.Email = Email;
}
}
And I have the dataAccess
class with method to view the records from the table.
public List<Developers> DeveloperList() throws SQLException{
ResultSet set;
String sql ="select DeveloperName , password_, Email from developers";
Connection conn;
conn = DbConnection.ConnectDb();
List<Developers> DeveloperList=new ArrayList();
PreparedStatement preparedstate = conn.prepareStatement(sql);
set = preparedstate.executeQuery();
while(set.next()){
String name = set.getString(1);
String password = set.getString(2);
String Email = set.getString(3);
Developers dev = new Developers(name,password,Email);
DeveloperList.add(dev);
}
return DeveloperList;
}
}
And Servlet as given below
public class DisplayDevelopers extends HttpServlet {
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse
response)
throws ServletException, IOException {
try {
DataAccess.DeveloperAccess DataAccess = new DataAccess.DeveloperAccess();
request.setAttribute("DisplayDevelopers", DataAccess.DeveloperList());
RequestDispatcher rd = request.getRequestDispatcher("Developers.jsp");
rd.forward(request, response);
processRequest(request, response);
} catch (SQLException ex) {
Logger.getLogger(DisplayDevelopers.class.getName()).log(Level.SEVERE, null, ex);
}
}
My jsp page as below
<% List<Developers> DisplayDevelopers = (List<Developers>) request.getAttribute("DisplayDevelopers");
pageContext.setAttribute("DisplayDevelopers", DisplayDevelopers); %>
<table>
<tr><th>Developer Name</th>
<th>Developer Password</th>
<th>Email</th>
</tr>
<c:forEach items="${DisplayDevelopers}" var="DisplayDevelopers">
<tr><td><c:out value="${DisplayDevelopers.developerName}"/></td>
<td><c:out value="${DisplayDevelopers.developerPassword}"/></td>
<td><c:out value="${DisplayDevelopers.Email}" /></td></tr>
</c:forEach>
</table>
The problem is it does not display data ? I am kind of new to Java web development am I doing something wrong here?
Any suggestions?
java servlets jsp
New contributor
I have a table called Developers
.
DeveloperName | password_ | Email
john 1234 john@gmail.com
Rose 5678 Rose@gmail.com
Developer Class
public class Developers {
private int developer_id;
private String developerName;
private String developerPassword;
private String Email;
public Developers(int developer_id, String developerName, String
developerPassword, String Email) {
this.developer_id = developer_id;
this.developerName = developerName;
this.developerPassword = developerPassword;
this.Email = Email;
}
public Developers(String developerName, String developerPassword, String Email) {
this.developerName = developerName;
this.developerPassword = developerPassword;
this.Email = Email;
}
public int getDeveloper_id() {
return developer_id;
}
public String getDeveloperName() {
return developerName;
}
public String getDeveloperPassword() {
return developerPassword;
}
public String getEmail() {
return Email;
}
public void setDeveloper_id(int developer_id) {
this.developer_id = developer_id;
}
public void setDeveloperName(String developerName) {
this.developerName = developerName;
}
public void setDeveloperPassword(String developerPassword) {
this.developerPassword = developerPassword;
}
public void setEmail(String Email) {
this.Email = Email;
}
}
And I have the dataAccess
class with method to view the records from the table.
public List<Developers> DeveloperList() throws SQLException{
ResultSet set;
String sql ="select DeveloperName , password_, Email from developers";
Connection conn;
conn = DbConnection.ConnectDb();
List<Developers> DeveloperList=new ArrayList();
PreparedStatement preparedstate = conn.prepareStatement(sql);
set = preparedstate.executeQuery();
while(set.next()){
String name = set.getString(1);
String password = set.getString(2);
String Email = set.getString(3);
Developers dev = new Developers(name,password,Email);
DeveloperList.add(dev);
}
return DeveloperList;
}
}
And Servlet as given below
public class DisplayDevelopers extends HttpServlet {
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse
response)
throws ServletException, IOException {
try {
DataAccess.DeveloperAccess DataAccess = new DataAccess.DeveloperAccess();
request.setAttribute("DisplayDevelopers", DataAccess.DeveloperList());
RequestDispatcher rd = request.getRequestDispatcher("Developers.jsp");
rd.forward(request, response);
processRequest(request, response);
} catch (SQLException ex) {
Logger.getLogger(DisplayDevelopers.class.getName()).log(Level.SEVERE, null, ex);
}
}
My jsp page as below
<% List<Developers> DisplayDevelopers = (List<Developers>) request.getAttribute("DisplayDevelopers");
pageContext.setAttribute("DisplayDevelopers", DisplayDevelopers); %>
<table>
<tr><th>Developer Name</th>
<th>Developer Password</th>
<th>Email</th>
</tr>
<c:forEach items="${DisplayDevelopers}" var="DisplayDevelopers">
<tr><td><c:out value="${DisplayDevelopers.developerName}"/></td>
<td><c:out value="${DisplayDevelopers.developerPassword}"/></td>
<td><c:out value="${DisplayDevelopers.Email}" /></td></tr>
</c:forEach>
</table>
The problem is it does not display data ? I am kind of new to Java web development am I doing something wrong here?
Any suggestions?
java servlets jsp
java servlets jsp
New contributor
New contributor
edited 14 hours ago
mdfst13
17.1k42155
17.1k42155
New contributor
asked 15 hours ago
Ryan
1
1
New contributor
New contributor
put on hold as off-topic by mdfst13, πάντα ῥεῖ, Mathias Ettinger, Heslacher, Graipher 13 hours ago
This question appears to be off-topic. The users who voted to close gave this specific reason:
- "Code not implemented or not working as intended: Code Review is a community where programmers peer-review your working code to address issues such as security, maintainability, performance, and scalability. We require that the code be working correctly, to the best of the author's knowledge, before proceeding with a review." – mdfst13, πάντα ῥεῖ, Mathias Ettinger, Heslacher, Graipher
If this question can be reworded to fit the rules in the help center, please edit the question.
put on hold as off-topic by mdfst13, πάντα ῥεῖ, Mathias Ettinger, Heslacher, Graipher 13 hours ago
This question appears to be off-topic. The users who voted to close gave this specific reason:
- "Code not implemented or not working as intended: Code Review is a community where programmers peer-review your working code to address issues such as security, maintainability, performance, and scalability. We require that the code be working correctly, to the best of the author's knowledge, before proceeding with a review." – mdfst13, πάντα ῥεῖ, Mathias Ettinger, Heslacher, Graipher
If this question can be reworded to fit the rules in the help center, please edit the question.
4
Non-working code is off-topic for this site. If you pare down your current code into a MCVE (the smallest amount of code that still shows the problem), it should be on-topic on Stack Overflow. However, you might find that it is a duplicate of an existing question there. Hint: I think thattaglib
might be required to useforEach
. Also, JSP in general has been deprecated in favor of JSF. You might be better off switching now.
– mdfst13
14 hours ago
(Try not to keep readers of your post scrolling down to find out what your question is.)
– greybeard
14 hours ago
add a comment |
4
Non-working code is off-topic for this site. If you pare down your current code into a MCVE (the smallest amount of code that still shows the problem), it should be on-topic on Stack Overflow. However, you might find that it is a duplicate of an existing question there. Hint: I think thattaglib
might be required to useforEach
. Also, JSP in general has been deprecated in favor of JSF. You might be better off switching now.
– mdfst13
14 hours ago
(Try not to keep readers of your post scrolling down to find out what your question is.)
– greybeard
14 hours ago
4
4
Non-working code is off-topic for this site. If you pare down your current code into a MCVE (the smallest amount of code that still shows the problem), it should be on-topic on Stack Overflow. However, you might find that it is a duplicate of an existing question there. Hint: I think that
taglib
might be required to use forEach
. Also, JSP in general has been deprecated in favor of JSF. You might be better off switching now.– mdfst13
14 hours ago
Non-working code is off-topic for this site. If you pare down your current code into a MCVE (the smallest amount of code that still shows the problem), it should be on-topic on Stack Overflow. However, you might find that it is a duplicate of an existing question there. Hint: I think that
taglib
might be required to use forEach
. Also, JSP in general has been deprecated in favor of JSF. You might be better off switching now.– mdfst13
14 hours ago
(Try not to keep readers of your post scrolling down to find out what your question is.)
– greybeard
14 hours ago
(Try not to keep readers of your post scrolling down to find out what your question is.)
– greybeard
14 hours ago
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
4
Non-working code is off-topic for this site. If you pare down your current code into a MCVE (the smallest amount of code that still shows the problem), it should be on-topic on Stack Overflow. However, you might find that it is a duplicate of an existing question there. Hint: I think that
taglib
might be required to useforEach
. Also, JSP in general has been deprecated in favor of JSF. You might be better off switching now.– mdfst13
14 hours ago
(Try not to keep readers of your post scrolling down to find out what your question is.)
– greybeard
14 hours ago