Trouble with database data retrieving!!!Please someone help me!!

Hello people!!
I'm havin g a trouble in getting the data from a bean , someone could give me a hand?
That's the following: The Database class get a conection, a DetalhesLivro.class arraylist
is obtained with the method getBooks, and I start my servlets apllication with contextListener
where i staciate this class, so when i retrieving the value the browser keep too long loading
and give me no data from the class here is piece of code :
the context:
package servlets;
import java.sql.Connection;
import java.sql.SQLException;
import javax.servlet.*;
public final class Contexto implements ServletContextListener{
private ServletContext context = null;
public Database db;
public void contextInitialized(ServletContextEvent event) {
context = event.getServletContext();
try {
db = new Database();
context.setAttribute("dados", db);
} catch (Exception ex) {
System.out.println("Imposs�vel a cria��o do bean:" +
ex.getMessage());
public void contextDestroyed(ServletContextEvent event) {
context = event.getServletContext();
Database lixo = (Database)context.getAttribute("dados");
if (lixo != null)
lixo.remove();
and this is the class to retrieving the data :
package servlets;
import java.io.*;
import java.sql.SQLException;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class Resultado extends HttpServlet {
DetalhesLivros livro;
Database db;
ArrayList livros;
public void init() throws ServletException {
db = (Database)getServletContext().getAttribute("dados");
if (db == null){
throw new UnavailableException("Couldn't get database.");
public void destroy() {
db = null;
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
/* HttpSession session = request.getSession();
procura = (Procura)session.getAttribute("dados"); */
response.setContentType("text/html");
response.setBufferSize(8192);
String valorRadio = request.getParameter("radio");
String valorInput = request.getParameter("campo");
try{
livros = db.getBooks();
}catch(Exception e){
e.getMessage();
PrintWriter out = response.getWriter();
// then write the data of the response
out.println("<html><head><title>Livraria Online!!!</title></head><body><div align=\"center\"><p><strong>"+
"<p><font size=\"+7\">Loja de Livros</font></p>");
Iterator iterator = livros.iterator();
try{
while(iterator.hasNext()){
if(valorRadio=="titulo"){
livro = (DetalhesLivros)iterator.next();
if(livro.getTitulo()==valorInput){         
out.println("<p> </p><p><strong>Nome do Livro:"+livro.titulo+
"</strong></p><p><strong>Autor:"+livro.autor+"</strong></p><p><strong>Pre&ccedil;o:"+livro.getPreco()+"</strong>"+
"</p><p><strong>C&oacute;digo:"+livro.getCod()+"</strong></p>");
break;
break;
}catch(Exception e){
e.getMessage();
out.println("<p></p><br><br><br><table width=\"48%\" border=\"0\"><tr><td width=\"60%\"><a href=\"\"><strong>Pesquisar</strong>"+
"</a></td><td width=\"40%\"><a href=\"\"><strong>Listar</strong></a></td></tr></table><strong>"+
"</strong></div></body></html>");
out.close();
thanks a lot for some help!!!

sorry!!
package servlets;
import java.sql.Connection;
import java.sql.SQLException;
import javax.servlet.*;
public final class Contexto implements ServletContextListener{
    private ServletContext context = null;
    public Database db;  
    public void contextInitialized(ServletContextEvent event) {
        context = event.getServletContext();             
        try {
              db = new Database();
              context.setAttribute("dados", db);
        } catch (Exception ex) {
            System.out.println("Imposs�vel a cria��o do bean:" +
                ex.getMessage());
    public void contextDestroyed(ServletContextEvent event) {
        context = event.getServletContext();
        Database lixo = (Database)context.getAttribute("dados");
        if (lixo != null)            
               lixo.remove();                     
}package servlets;
import java.io.*;
import java.sql.SQLException;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class Resultado extends HttpServlet {
DetalhesLivros livro;
Database db;
ArrayList livros;
public void init() throws ServletException {
db = (Database)getServletContext().getAttribute("dados");
if (db == null){
throw new UnavailableException("Couldn't get database.");
public void destroy() {
db = null;
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
/* HttpSession session = request.getSession();
procura = (Procura)session.getAttribute("dados"); */
response.setContentType("text/html");
response.setBufferSize(8192);
String valorRadio = request.getParameter("radio");
String valorInput = request.getParameter("campo");
try{
livros = db.getBooks();
}catch(Exception e){
e.getMessage();
PrintWriter out = response.getWriter();
// then write the data of the response
out.println("<html><head><title>Livraria Online!!!</title></head><body><div align=\"center\"><p><strong>"+
"<p><font size=\"+7\">Loja de Livros</font></p>");
Iterator iterator = livros.iterator();
try{
while(iterator.hasNext()){
if(valorRadio=="titulo"){
livro = (DetalhesLivros)iterator.next();
if(livro.getTitulo()==valorInput){         
out.println("<p> </p><p><strong>Nome do Livro:"+livro.titulo+
"</strong></p><p><strong>Autor:"+livro.autor+"</strong></p><p><strong>Pre&ccedil;o:"+livro.getPreco()+"</strong>"+
"</p><p><strong>C&oacute;digo:"+livro.getCod()+"</strong></p>");
break;
break;
}catch(Exception e){
e.getMessage();
out.println("<p></p><br><br><br><table width=\"48%\" border=\"0\"><tr><td width=\"60%\"><a href=\"\"><strong>Pesquisar</strong>"+
"</a></td><td width=\"40%\"><a href=\"\"><strong>Listar</strong></a></td></tr></table><strong>"+
"</strong></div></body></html>");
out.close();
--------------------------------------------------------------------------------------------

Similar Messages

  • GX640 UK/Europe release date? (please someone help!)

    Hi,
    I am dying to purchase the new GX640 Gaming laptop from MSI. I know it's been released in the U.S. And Canada but it is absolutely impossible to find any release date for Europe 
    I live in London and have been calling MSI UK and MSI US, no one had a clue about any release date. I probably did not contact the right person though...
    Anyway, please, pleaaaaase someone provide me with some information on an upcoming European/UK release date. I want this laptop soooo bad 

    All I can tell you so far, is that it is available in the netherlands. *looks at his own*
    Some do send to other countries, but keep in mind they will have a US keyboard layout and not the UK one.
    A good webshop I myself order enough things at and do international shipping (though the website is in dutch only)
    http://www.4launch.nl/shop/product/091211/-notebook-gx640-084nl-15-4---i5-430m--500gb--w7/tweakers
    Another website that does get good reviews is the below, which is also in english and does international/european shipping
    http://www.webconnexxion.com/raid/product_info.php?products_id=19252
    But as said, dont forget the different keyboard layout!

  • HT1893 I just bought a MAC and can't figure out how to use the scan feature on my RX580 HP printer.  Can anyone tell me where to find this?  This used to be an option that was obvious under programs with my Dell.  Please someone help!

    I need some help!  I was able to download my HP printer software on to my Macbook Pro, but cannot find the Scan feature on the computer to be able to scan a document.  If someone could LMK what I need to do, or where I need to look to find this I would appreciate it!

    That would be a function of the driver that came with the printer. Make sure you have the latest driver appropriate to your system, either from HP or:
    Printer and Scanner software available for download:
    http://support.apple.com/kb/HT3669?viewlocale=en_US

  • I changed my itunes password only and now I can't update any of the apps I downloaded using the old password. I tried signing in with the old password with no luck. Can someone help please?

    I changed my itunes password only and now I can't update any of the apps I downloaded using the old password. I tried signing in with the old password with no luck. Can someone help please?

    Have you signed out of your iTunes account on the device/computer that you are using and signed back in with the updated password ? That should 'refresh' the account on it, and you should be able to use the account's new password to download updates to its apps

  • Why is "erase junk mail" de-highlighted in the drop down menus.  I'm not able to delete my junk mail box without doing each one individually.  Simple, but please someone help with an answer.  Thanks.

    why is "erase junk mail" de-highlighted in the drop down menus.  I'm not able to delete my junk mail box without doing each one individually.  Simple, but please someone help with an answer.  Thanks.

    My daughter has had her Razr for about 9 months now.  About two weeks ago she picked up her phone in the morning on her way to school when she noticed two cracks, both starting at the camera lens. One goes completely to the bottom and the other goes sharply to the side. She has never dropped it and me and my husband went over it with a fine tooth comb. We looked under a magnifying glass and could no find any reason for the glass to crack. Not one ding, scratch or bang. Our daughter really takes good care of her stuff, but we still wanted to make sure before we sent it in for repairs. Well we did and we got a reply from Motorola with a picture of the cracks saying this was customer abuse and that it is not covered under warranty. Even though they did not find any physical damage to back it up. Well I e-mailed them back and told them I did a little research and found pages of people having the same problems. Well I did not hear from them until I received a notice from Fed Ex that they were sending the phone back. NOT FIXED!!! I went to look up why and guess what there is no case open any more for the phone. It has been wiped clean. I put in the RMA # it comes back not found, I put in the ID #, the SN# and all comes back not found. Yet a day earlier all the info was there. I know there is a lot more people like me and all of you, but they just don't want to be bothered so they pay to have it fix, just to have it do it again. Unless they have found the problem and only fixing it on a customer pay only set up. I am furious and will not be recommending this phone to anyone. And to think I was considering this phone for my next up grade! NOT!!!!

  • I have a mac book pro and have already downloaded adobe flash player. However when i go to watch a video it says "Block Plug In". But my adobe is already up to date. Can someone help me to fix this so i can watch videos?

    I have a mac book pro and have already downloaded adobe flash player. However when i go to watch a video it says "Blocked Plug In". But my adobe is already up to date. Can someone help me to fix this so i can watch videos?

    If you're sure you've installed the latest version of Flash, take each of the following steps that you haven't already tried. After each step, relaunch Safari and test. For a "missing plug-in" error, start with Step 7. Back up all data before making any changes.
    Step 1
    You might have to log out or reboot before a Flash update takes effect.
    Step 2
    In the Safari preference window, select
    Privacy ▹ Remove All Website Data
    Close the window. Then select
     ▹ System Preferences… ▹ Flash Player ▹ Advanced
    and click Delete All. Close the preference pane.
    Step 3
    If you're only having trouble with YouTube videos, log in to YouTube and load this page. You may see a link with the text "Leave the HTML5 Trial." If so, click that link.
    Step 4
    If you get a warning of a "blocked" or "outdated" plug-in, then from the menu bar select
     ▹ System Preferences… ▹ Flash Player ▹ Advanced
    and click Check Now. Quit and relaunch the browser.
    If the warning persists, triple-click anywhere in the line below on this page to select it:
    /System/Library/CoreServices/CoreTypes.bundle/Contents/Resources
    Right-click or control-click the highlighted text and select
    Services ▹ Open
    from the contextual menu.* A folder should open. Inside it, there should be a file named "XProtect.meta.plist". If that file is missing and you know why it's missing, restore it from a backup or copy it from another Mac running the same version of OS X. Otherwise, reinstall OS X.
    *If you don't see the contextual menu item, copy the selected text to the Clipboard by pressing the key combination command-C. In the Finder, select
    Go ▹ Go to Folder...
    from the menu bar, paste into the box that opens (command-V). You won't see what you pasted because a line break is included. Press return.
    Step 5
    Open this folder as in Step 4:
    /Library/Internet Plug-Ins
    Delete the following item, or anything with a similar name, if present:
    Flash Player (failing).plugin  
    You may be prompted for your login password.
    Step 6
    Re-download and reinstall Flash. Download it from the domain "get.adobe.com". Don't click a link from any other website, including this one, because you can't trust links. They may be an attempt to trick you into installing malware masquerading as Flash. Type the address into the browser window. Never download a Flash update from anywhere else.
    Step 7
    If you get a "missing plug-in" error, select
    Safari ▹ Preferences... ▹ Security
    from the Safari menu bar and check the box marked
    Allow (or Enable) plug-ins
    Then click the button marked
    Manage Website Settings...
    if present and make sure that the website is not blocked for Flash.
    Step 8
    Select
    Safari ▹ Preferences... ▹ Extensions
    from the Safari menu bar. If any extensions are installed, disable them.

  • Big problem installing... Please someone help :-(

    Ok I started up the bootcamp assistant (with my windows xp disc already in the MacBook) and continued to partition the drive as shown on the video demonstration on the apple website. I believe I gave it 80gb for windows and the rest of the 250gb to the mac. I believe this was about 70gb. Now once the partitioning was done the windows installer automatically came up without me pressing anything. It went through a short installation process on a blue screen and came up with the option to choose a partition.
    This is where I realised there was an issue. There was only one option present for the partitions. This partition was called partition 1 and had around 120gb all of which was available. I thought this didn't look correct so I quit out. A warning came up saying that the installation wasn't complete. Now when I start the mac is goes to a plane black screen. If I start it up holding the alt key it only displays one hard drive named windows.
    I am now very worried all my stuff stored on the mac is is gone. Can someone please explain what I did wrong because I didn't format the drive or anything and so did not delete anything at all on the hard drive. I feel like everything should be there but I can't get into it. Putting in my os install disc didn't help at all. Please someone help!

    I think its that its tried to install it on my initial partition for some reason. But like I said I did not even go far enough to choose a partition. It did some installation stuff on the blue screen without me pressing a single button. The minute it wanted me to pick a partition and then format it I realised there was something wrong and backed out. I have no idea why it is now coming up as windows. My main question really is: is there anyway to get it back to what it was? I would really appreciate any help on this matter as I feel a bit out of my depth
    NOTE: I realise it was ridiculous of me to do it without first backing up all my data, however the video made it look fool-proof and also I only was planning at that point to create the partition first. But as soon as I created the partition the blue screen came up and it started to install. I pressed nothing at all at that point, and it didnt take very long so I couldnt see how it would delete all my data.
    Message was edited by: ExO_PoLiTiX

  • 25k Limit in iTunes Match? PLEASE SOMEONE HELP!

    I have been collecting music steadily for almost 25 years now. In 2009, before selling them on eBay, I had over 2,000 CDs in my collection. At that point I ripped them all into iTunes and stored the files on an external drive. I have continued to steadily collect music since then...ripping CDs borrowed from friends, free (and legal) downloads, bit torrent concert DLs from places like Archive.org and yes, many purchases from the iTunes store. 
    Currently I have 45,962 songs, weighing in at just shy of 264 GB. I have a 260 GB iPod Classic which I LOVE, but unfortunately outgrew quite some time ago (260 actually means 241 or so). Needless to say, I have very eclectic taste in music, and one thing I LOVE to do is listen to my ENTIRE collection on shuffle. I also have 30-or-so playlists which I add tracks to as they come up on shuffle. Once I reached the limit on my iPod, I set it to only sync checked songs and began systematically unchecking songs I don't like or like "not-as-much." This worked fine for some time, but I am all out of files to "uncheck" (I tend to only buy music I like). Additionally, I now need to quickly uncheck a bunch of files every time I get new music, if I want to listen to it on my iPod. For some time I held onto some hope that Apple would put out a 320 GB Classic, but sadly that is never going to happen.
    I have a 16 GB iPhone 5, but storing music in that would be ridiculous.
    Since getting my Mac, I have a renewed passion for my iTunes library and music collection (not-so-fun with semi-functional PCs). I am finally able to organize my library like I like to, and would LOVE to be able to access it remotely.  A friend recently told me to check out iTunes Match, which reads like Storybook Fantasy in its description. Imagine my disappointment to learn that there's a 25k song limit! Tracks purchased from iTunes don't count toward the 25k, but I am not about to start re-buying 90% of my music just to use iTunes Match. I purchased a 3T WD My Cloud, hoping that would solve the issue, but apparently Apple's proprietary restrictions prevent the iTunes server from streaming remotely on my device using this service.
    I read here in the forums, someone's instructions on how to essentially have TWO libraries, scaling one down to 25k...WHAT? I'd be better off just sticking with my Classic, which fits around 33k songs!
    PLEASE SOMEONE HELP...Does anyone out there know of any way to accomplish what I want to do? I want to be able to access and play my entire music library (about 46,000 songs and growing), through iTunes (playlists, play count intact), through an app on my phone.
    I own the following equipment:
    (Late 2014) 13" MacBook Pro with Retina Display (running OS Yosemite)
    260 GB iPod Classic
    16 GB iPhone 5 (running iOS 8.1.2)
    WD 3T My Book
    WD 3T My Cloud
    Thank you. Please help. Thank you.
    <Edited By Host>

    Jimzgoldfinch wrote:
    Why is it nonsense?
    iCloud Drive storage is not the same as iTunes match. ITunes Match does not store your music but matches with what's on the Apple servers and uploads non matched music.
    jim
    Where shall I start?
    The music that is uploaded to iTunes Match (as you mentioned) is stored in iTunes Match. If it is not then where exactly is it?  User uploaded tracks are subject to a 25,000 limit. There is no limit to the amount of iTunes purchased music.
    All music stored in Match (either uploaded by you or purchased from iTunes by you) is available for streaming or download to an IOS or OSX device (Windows may be download only)
    It's nonsense because it is almost entirely incorrect.

  • Hi everybody,please someone help me,i had a 3gs last year and i bought a 4,but itunes doesn't synch videos from photos file and it crashes,every time i try to synch photos it stacks when videos try to synch and crashes,what to do please?

    hi everybody,please someone help me,i had a 3gs last year and i bought a 4,but itunes doesn't synch videos from photos file and it crashes,every time i try to synch photos it stacks when videos try to synch and crashes,what to do please?

    hi i had the same problem today when i updated my itunes to latest version. however, i have just found my songs in the 'itunes media' folder. this was accessed through 'my music'  then keep clicking through until you find itunes media and all my library songs were in there and i then just added these files to my library and all were restored however, i have lost all my playlists but at least my 700 songs are back. very dissapointed with apple that they have let this happen with their latest update, the previous version was miles better than this one . hope you find them. stevo

  • I can't get adobe reader x to copy a column with the alt key, can someone help me.

    I can't get adobe reader x to copy a column with the alt key, can someone help me.

    Hello Pat,
    Thank you for getting back to me.  I have a table with columns in it and I’m trying to copy just one of the columns, think of it as a stock table you would get in a newspaper and I just want to copy the column that has all the symbols in it.  I use to be able to do this with no problem in previous versions of Adobe Reader by just putting my cursor next to the column I wanted, holding down the Alt key and selecting the data I wanted .  But with the new version that came with my new laptop running Window 8.0 I can not  accomplish this task.  Adobe Reader wants to copy everything in the table.  I would take a screen shot to show you, but when I open Reader, it takes over my entire screen and I can not get back to my task bar or desktop without closing the app.  If you could also tell me how to correct or adjust this annoyance I would appreciate it.   Needless to say I’m not currently a big fan of the new version of Reader.  Is there any way I can go back to a previous version of the product with Windows 8 as my OS?
    Thanks you for your help with this,
    Ed

  • Please, oh Please someone help me.  My FCP keeps quitting unexpectedly and I'm in the middle of my biggest project ever. I need help!

    My FCP keeps quitting unexpectedly, it’ll start load up and then quit around 16% of loading my project.  Please, someone help me this is my biggest project.

    You do know where the project is, don't you? Select the project in the finder and get info for thr project. How big is the file.
    You can find how to trash your preferences <a class="jive-link-external" href="http://www.fcpbook.com/Misc1.html">here</a>.
    You do have the media on separate drive, don't you? If yes, unmount the drive with the application closed. Drag it to the trash. Trash your preferences. Launch the application. Reset the scratch disk if you have to. Open the project. What happens?

  • Every apple email I receive is in Japanese. I don't even speak Japanese. Please someone help me!!, Every apple email I receive is in Japanese. I don't even speak Japanese. Please someone help me!!

    It also happens on my iPad and MacBook Pro because I use the same email address on them both. Please someone help me. It's only the apple emails by the way.

    Your password was sent to your emergency email address.  Perhaps you have an email you never use?   I use the free email from my cable TV account as my emergency email.
    Your Apple account and cloud account are separate.   You could even have completely different user and password.   Most of us use the same user ID and password, but they are not the same thing, don't mix them up.
    If you can't retrieve emergency email, you will have to call apple support.
    http://support.apple.com/kb/HE57

  • My itunes library is empty but i want to upgrade my ipod without losing my music. how can i do this? please someone HELP!!!

    i recently got a new laptop so my itunes library is empty but i want to upgrade my ipod without losing my music. how can i do this? please someone HELP!!!

    but i got music from my old laptop and my little brothers laptop so basically its no way i can take whats already on my ipod and put it on my computer and drag and drop it to my new itunes library

  • Hey iphone an iphone 3g and i only have about 13 apps and the yellow bar on itunes for my phone is way to big i deleted all my photos all my music every thing i ryed restoring ans all it still takes up space for sum reason ?? please someone help me

    hey iphone an iphone 3g and i only have about 13 apps and the yellow bar on itunes for my phone is way to big i deleted all my photos all my music every thing i ryed restoring ans all it still takes up space for sum reason ?? please someone help me

    If Other (the yellow bar) is too big something is corrupted.  The only solution (that I know of) is to restore from your most recent backup using iTunes (see http://support.apple.com/kb/ht1766).

  • My phone 5s did the new update and will not come back on. I already tried hard reboot still won't work. Been over a hour now. Please someone help I need my phone.

    My phone 5s 16gb gold did the new update and will not come back on. I already tried hard reboot still won't work. Been over a hour now. Please someone help I need my phone.   This phone is not even 6 months old been in case no scratches. This is driving me crazy.

    Connect your phone to a computer and restore your software using iTunes.

Maybe you are looking for