# How to get and iterate questions in ember from database

**URL:** <https://discuss.emberjs.com/t/how-to-get-and-iterate-questions-in-ember-from-database/18983>\
**Category:** Questions\
**Created:** [July 9, 2021, 7:30am UTC](https://discuss.emberjs.com/t/how-to-get-and-iterate-questions-in-ember-from-database/18983 "2021-07-09T07:30:01Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![hari\_s18](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/hari_s18/32/17483_2.png) [@hari\_s18](https://discuss.emberjs.com/u/hari_s18)\
**Post date:** [July 9, 2021, 7:30am UTC](https://discuss.emberjs.com/t/how-to-get-and-iterate-questions-in-ember-from-database/18983/1 "2021-07-09T07:30:02Z")

</div>

I have written this code in JSP but I wanted the html codes to be in emberJS for that **I wanted to send the ResultSet to emberJS and iterate the questions in emberJS**. I am newbie to emberJS. Can anyone help me to get through this? Thanks in advance 🙂

_Below is my JSP code_

```auto
<%@page import="dao.MainDao" %>
<%@page import="java.sql.ResultSet" %>

<title>Delete Question</title>

<h1>Online Feedback System</h1>
<h2>Delete Question</h2>

<table align="center" cellpadding="5" cellspacing="5" border="1">
<tr>

</tr>
<tr>
<td><b>Q ID</b></td>
<td><b>QUESTION</b></td>

</tr>

<% 
ResultSet resultSet = MainDao.displayQuestions();
while(resultSet.next())
{
%>
<tr>
<td><%=resultSet.getString("qid") %></td>
<td><%=resultSet.getString("questionmessage") %></td>
</tr>
<% 
}

%>

</table><br><br>

<form>
Enter the Question ID to delete : <input type="text" name="qid" >
<input type="submit" value="submit">
</form>

<script src="https://code.jquery.com/jquery-3.5.1.min.js"></script>

<script>

$(document).ready(function(){
    $("form").on("submit", function(event){
        event.preventDefault();
 
        var formValues= $(this).serialize();
 
        $.post("deletequestionx.jsp", formValues, function(data){
            location.reload();

        });
    });
});

</script> 

```

---

<div class="post-metadata">

**Author:** ![ef4](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/ef4/32/13470_2.png) [@ef4](https://discuss.emberjs.com/u/ef4)\
**Post date:** [July 9, 2021, 2:19pm UTC](https://discuss.emberjs.com/t/how-to-get-and-iterate-questions-in-ember-from-database/18983/2 "2021-07-09T14:19:02Z")

</div>

If you haven’t already done it, the biggest piece of work here is exposing your data on an API endpoint. Same as we discussed in [How to connect mySQL and emberJS framework to send and retrieve data](https://discuss.emberjs.com/t/how-to-connect-mysql-and-emberjs-framework-to-send-and-retrieve-data/18910).

To load and display the list of questions, the simplest solution is to load the data from your route:

```nohighlight
// app/routes/my-page.js
import Route from '@ember/routing/route';
export default class extends Route {
  async model() {
    let response = await fetch('/your-questions-endpoint-here');
    let json = await response.json();
    return json;
  }
}

```

And then display it in the template like:

```nohighlight
{{!-- app/templates/my-page.hbs --}}
{{#each @model as |question|}}
<tr>
  <td>{{question.qid}}</td>
  <td>{{question.questionmessage}}</td>
</tr>
{{/each}}

```

---

<div class="post-metadata">

**Author:** ![hari\_s18](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/hari_s18/32/17483_2.png) [@hari\_s18](https://discuss.emberjs.com/u/hari_s18)\
**Post date:** [July 10, 2021, 3:07pm UTC](https://discuss.emberjs.com/t/how-to-get-and-iterate-questions-in-ember-from-database/18983/3 "2021-07-10T15:07:53Z")

</div>

Hi, Edward. Yes, I am serving it on apache tomcat sever at [http://localhost:8080/onlinefeedbacksystemFinal/deletequestion.jsp](http://localhost:8080/onlinefeedbacksystemFinal/deletequestion.jsp) As in the above JSP code I have iterated the resultset in java which is the query of the all the questions and question ids using JDBC. I guess I cannot return the java resultset to the ember. Is there any other way ? (Now my question is how to send the resultset which contains the questions and question ids to route)

---

<div class="post-metadata">

**Author:** ![ef4](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/ef4/32/13470_2.png) [@ef4](https://discuss.emberjs.com/u/ef4)\
**Post date:** [July 12, 2021, 5:42pm UTC](https://discuss.emberjs.com/t/how-to-get-and-iterate-questions-in-ember-from-database/18983/4 "2021-07-12T17:42:26Z")

</div>

I think what you’re missing is that you don’t want JSP to render HTML. You want it to render something that’s easier for your code to parse and consume – probably JSON. My sample code above assumes JSON. Where I wrote `/your-questions-endpoint-here`, that would be your `http://localhost:8080/onlinefeedbacksystemFinal/deletequestion.jsp`

---

<div class="post-metadata">

**Author:** ![hari\_s18](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/hari_s18/32/17483_2.png) [@hari\_s18](https://discuss.emberjs.com/u/hari_s18)\
**Post date:** [July 12, 2021, 5:57pm UTC](https://discuss.emberjs.com/t/how-to-get-and-iterate-questions-in-ember-from-database/18983/5 "2021-07-12T17:57:57Z")

</div>

Yes I am working on it, Thanks for considering my question 😃
