Once more!!can anyone help me ?
cold you help me with these codes, my jsp page brings
me no result, a blank page. Can you tell where's the mistake?
Thanks in advance!!
this is my context:
package teste;
import java.util.ArrayList;
import javax.servlet.*;
public final class ContextPage implements ServletContextListener {
private ServletContext context = null;
Data bookDB;
public void contextInitialized(ServletContextEvent event) {
context = event.getServletContext();
try {
bookDB = new Data();
context.setAttribute("bookDB", bookDB);
} catch (Exception ex) {
System.out.println("Couldn't create bookstore database bean: " +
ex.getMessage());
public void contextDestroyed(ServletContextEvent event) {
context = event.getServletContext();
Data dados = (Data) context.getAttribute("bookDB");
if (dados != null) {
dados.remove();
context.removeAttribute("bookDB");
} this is the class to store the data:
package teste;
public class Detalhes {
private String titulo;
private String autor;
private Double preco;
private int codigo;
public Detalhes(String titulo, String autor, Double preco, int codigo) {
this.titulo = titulo;
this.autor = autor;
this.preco = preco;
this.codigo = codigo;
public String getTitulo(){
return titulo;
public String getAutor(){
return autor;
public Double getPreco(){
return preco;
public int getCodigo(){
return codigo;
public void setTitulo(String titulo){
this.titulo = titulo;
public void setAutor(String autor){
this.autor = autor;
public void setPreco(double preco){
this.preco = preco;
public void setCodigo(int codigo){
this.codigo = codigo;
}this is my conection and where i call the object puting the data
package teste;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.logging.Level;
import java.util.logging.Logger;
public class Data {
PreparedStatement prepStmt;
ResultSet rs;
Connection con;
Detalhes detalhes;
int codigo;
ArrayList list;
public Data()throws Exception {
try {
Class.forName("org.gjt.mm.mysql.Driver");
con = DriverManager.getConnection("jdbc:mysql://127.0.0.1/loja?user=marcos&password=131283");
} catch (Exception ex) {
throw new Exception(" Database not found!!" +
ex.getMessage());
public void remove() {
try {
con.close();
} catch (SQLException ex) {
System.out.println(ex.getMessage());
public void setCodigo(int codigo){
this.codigo = codigo;
public Detalhes getDetalhes(){
try {
String selectStatement = "select * from livraria where codigo ?";
prepStmt = con.prepareStatement(selectStatement);
prepStmt.setInt(1, codigo);
rs = prepStmt.executeQuery();
while(rs.next())
detalhes = new Detalhes(rs.getString("titulo"), rs.getString("autor"), rs.getDouble("preco"), rs.getInt("codigo"));
prepStmt.close();
}catch(Exception e){
System.out.println(e.getMessage());
}finally {
// close prepared statements and result sets within finally blocks
if (rs != null) {
try {
rs.close();
} catch (SQLException sqle) {
System.out.println(sqle.getMessage());
if (prepStmt != null) {
try {
prepStmt.close();
} catch (SQLException sqle) {
System.out.println(sqle.getMessage());
return detalhes;
public ArrayList getList(){
try {
list = new ArrayList();
String selectStatement = "select * from livraria";
PreparedStatement prepStmt = con.prepareStatement(selectStatement);
ResultSet rs = prepStmt.executeQuery();
while(rs.next()){
detalhes = new Detalhes(rs.getString(1), rs.getString(2), rs.getDouble(3), rs.getInt(4));
list.add(detalhes);
prepStmt.close();
}catch(Exception e){
System.out.println(e.getMessage());
return list;
}and at last my jsp page
<p><b><h1>Resultado:</h1></b></p><br>
<jsp:useBean id="sourceData" class="teste.Data" scope="application" />
<c:set var="lista" value="${sourceData}">
<c:forEach var="book" begin="0" items="${lista}">
<p><b><h1>${book.titulo}</h1></b></p><br>
</c:forEach>why does it brings me a blank page?Thanks for replying!!
what are you printing out on the page?List of book titles :)
Soneca,
Your jsp is iterating over an ampty list, that's why you get a blank page. Data has to be set in scope, before you can use it in your jsp page. Your context listener sure has some stuff, but it sets an empty BookDB object - you have a lot of rework to do on your code.
cheers,
ram.
Similar Messages
-
My mac won't recognize an external monitor. The screen Goes Blue Once, then goes blue again and the second monitor just turns off. I am using an HDMI adapter to a visio TV. I also have my xbox on the tv. Can anyone Help??
Lol, figured out the first part. Just for those who may be searching, when you click on the Display Preferences, and click on the arraingment tab... it not only shows where your two screens will be displayed, but the WHITE BAR at the top of one screen is the dock/toolbar. Click and hold to grab this and just slide it over to the screen you'd like it to be on.
You have to release it IN the screen box, not on top of it... and it should pop right over to the new (or old) screen. At any rate, you can put the dock on either (or any) screen that you prefer.
I am thinking of ordering more of these. Lol. 3 monitor setup seems like it would be crazy good.
Still looking for the answer to keeping the new 16" screen on the right without switching between screen #s with that... not expose... Lion feature.
Thanks. Hope my other question has an answer out here.
Paul H -
I create an apple id then i want to verify it, i verify it once then when i log in with my apple id it asked mi again to verify it.everytime i log in it asked me to resend verication and after i resend it i press done. Please can anyone help me ?
How are you verifying it? Are you responding to the email that is sent? If not, do so.
If so, then try changing your password. -
ipone 4s display suddenly doesn't work any more. most of the time i can't even unlock my iphone as it puts the numbers itself. and if i am lucky to unlock it opens apps and does everything else whenever my finger comes near the display without even touching it. I did reset and also updated my operating system. But the problem stills shows up... can anyone help please?
Contact iTunes Customer Service and request assistance
Use this Link > Apple Support iTunes Store Contact -
I am trying to open a MPEG video clip using Quicktime and it wont let me, keeps saying a codec is required. So I click on tell me more, have downloaded Quicktime 7 on numerous occasions thinking this was the problem, and it still wont let me open in. Really confused! Can anyone help???
Try VLC.
-
i plugged in my ipod and now i get the error message: Because a USB device was drawing too much power from your computer, one or more of your USB devices have been disabled" - i have a MAcBook pro and now my USB ports do not work - can anyone help me ???
Sometimes you have to reset the SMC two or three times for it to work, don't know why. I've seen that error message before and 100% of the time it was fixed with an SMC reset. I suppose it's possible that your keyboard or mouse IS drawing too much power, do you have access to another you could try?
-
Hello. I have an iPad2, and iMovie software. My main problem, for the moment, is the length of the videos: I can´t create a video with more than 56 seconds. When I try, the app shuts off... Can anyone help me?
Sorry. We can't help you. It's no longer an iPhone. Apple won't touch it.
Take it to whoever replaced the screen and see if they can help you.
iPhones are not user servicable and Apple does not sell iPhone parts at all. I'd be surprised if you were actually able to back it up at this point. It sounds like it's completely borked. -
I have an iPod touch 4th gen that is in iOS 6.1 it's showing another update in the settings for iOS 6.1.6 but even if I wait for more than 30mins it won't show. Can anyone help me. Thank you and Godbless
- Reset the iOS device. Nothing will be lost
Reset iOS device: Hold down the On/Off button and the Home button at the same time for at
least ten seconds, until the Apple logo appears.
- Power off and then back on your router
.- Reset network settings: Settings>General>Reset>Reset Network Settings
- Try when connected to another network
- Update via iTunes on a computer. -
I bought something in a game for 5$ and didn't get anything but I was charged. This is happening more and more and I don't know what to do. Can anyone help me?
have you contacted the developers of the games to let them know?
-
I have downloaded a movie which has the extension .m4v. This will not play on my DVD player and I can't find software to convert it to a more universal format. Can anyone help?
If you've bought a film from iTunes then you can only copy it to a DVD or CD for backup purposes, you won't be able to watch it on a stand-alone DVD player.
-
I have an Imac G5 running on Mac OSX 10.4.11 and would like to upgrade to Lion. I need to upgrade to Snow Leopard first but the aplle dealer tell us here the Snow Leopard is no more available on Power PC. Can anyone help?
Does your Mac meet Lion's requirements?
Apple - OS X Lion - Technical specifications
Mac computer with an Intel Core 2 Duo, Core i3, Core i5, Core i7, or Xeon processor
2GB of memory
OS X v10.6.6 or later (v10.6.8 recommended)
7GB of available space
Some features require an Apple ID; terms apply.
Snow Leopard requirements:
General requirements
Mac computer with an Intel processor
1GB of memory
5GB of available disk space
DVD drive for installation -
My CC wont open. and Once again my LR and PS keep asking me to licence the software. I am a fully paid subscriber to CC. This issue keeps happening and was only fixed by Adobe lastnight, but its happening again can anyone HELP?
This is an open forum with a mix of other users and Adobe staff, not Adobe support... you need Adobe support
Adobe contact information - http://helpx.adobe.com/contact.html may help
-Select your product and what you need help with
-Click on the blue box "Still need help? Contact us" -
once again my iphone not working. i have a usb sign pointing to an itune icon on the screen. this is been on for over 24 hours. tried to restore but keeps coming up with era can anyone help please
What is the error that is occurring? We are not mind readers.
-
I am trying to sync. I have a 64gb phone with 19gb free. I have about 32gb of content. It tells me there is insufficient space and I need 12gb more. I think this is because it is trying to copy everything again. Can anyone help?.
Make sure that yo have the boxed chanced to only sync the checked music. It appears that it is trying to sync ore than those.
You can try unsycing all music and resyncing. -
I have an mpeg video from someone who is on PC. My mac wont play it. Says I need more software. Can anyone help?
VideoLAN - Download official VLC media player for Mac OS X
-
Can anyone help? Need to collect 4 or more pdf-files into one file
Hi,
I regurarly need to mail pdf-files. I'm searching an app or program that can collect 4 or more different pdf-files into one file. So I don't need to send them all apart.
Can anyone help me out?
Thanx!
TheoOpen Preview, open the PDFs you want to combine, select View/Show Thumbnail, drag the PDFs, you want to combine to the first PDF, then Export as PDF.
Preview Help
Maybe you are looking for
-
Getting Data from Maintenance view V001N into ABAP program
Hello Experts, I have to fetch data from the maintenance view V001N in my ABAP program. I have used select statement in my program but I am getting a syntax error 'V001N is not defined in the ABAP Dictionary as a table, projection view or database
-
I have what looked like a small bug that ran up and down the screen and then sudenly stopped in center upper half of screen and now appears to be burned in to the inside of the screen, anyone had this probelm before and what can be done about it?
-
No Easy Way to Join on Tables from Different Schemas
Hi, The company policy does not allow to join on tables from different schemas or use db links... I'm tasked to come up with a Perl script that does exactly that - allows for the SELECT statement to do several joins on 3 different schemas. In additio
-
Querying the schema for table name with column value!
In my schema i have 500+ tables and other objects. i have a column with the name BO_PRODUCT_CODE. I wants to know in what tables the value of BO_PRODUCT_CODE='FX03'. i have query the user_tab_columns which gives me the result with 90 tables having th
-
My headset is paired ,but not connected
My headset is paired but it is not connected,can anybody help please