Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Fail to retrieve data from database and shows in JSP page  RSS feed

 
krauser Hoe
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi! this is my first post and this is the first time I develop website using Java EE so a lot of syntax I really not aware but my problem is the code that supposed to retrieve data from database in JSP page does not invoked in servlet so the query within the model does not execute. I have already tested the Model class and when running the code netbean also not showing any error only shows"visit unvisit reference " so my major problem come downs to JSP. below are my JSP code:

<form name ="frmShowData" action ="editTrainControl" >
<table border ="1">
<thead>
<tr>
<th colspan ="10"><center><h4><b>Train Details</b></h4></center></th>
</tr>
</thead>
<th>Train ID </th>
<th>Departure Location </th>
<th>Arrival Location </th>
<th>Departure Time </th>
<th>Arrival Time </th>
<th>Departure Date </th>
<th>Arrival Date </th>
<th>Number of Stop </th>
<th>Number of Seat </th>
<th>Price </th>
<c:forEach items ="${requestScope.list}" var="admin">

<tr>
<td><a href = "${pageContext.request.contextPath}/insertTrainControl?tid = ${admin.getTid()}">${admin.getTid()}</a></td>

<td><a href ="${pageContext.request.contextPath}/editTrainControl?sloc = ${admin.getSloc()} ">${admin.getSloc()}</a></td>
<td>${admin.getEloc()}</td>
<td>${admin.getStime()}</td>
<td>${admin.getEtime()}</td>
<td>${admin.getSdate()}</td>
<td>${admin.getEdate()}</td>
<td>${admin.getStop()}</td>
<td>${admin.getSeat()}</td>
<td>${admin.getPrice()}</td>
</tr>
</c:forEach>

im not sure the correctness of my syntax but the code does not execute at all
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66142
141
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch.

By "not execute at all" what do you mean? Do you get no page displayed at all? How are you invoking the page? Through a servlet controller? If so, we'll need to see that. If not, then what's setting up the request scoped variables?

And please UseCodeTags.
 
krauser Hoe
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the pattern that I wrote the code is in MVC pattern but i wrote the model and ejb code within the same java class therefore i'm not sure where to posted it. Back to the question, there is another function before the function i posted above, that function is use to insert the data into database and it work perfect and the code I use to retrieve the table i have inserted is fails to execute and I don't know why because netbean only shows "visit unvisit reference" when I execute the page and I tried to include multiple out.println in the query code witihin the model page and non of them is printed out so I'm pretty sure the Servlet page does not invoked when the page is runnning below are the code for my JSP page, servlet and model

JSP code



Servlet Code



Model Code

 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!