Error in updating and displaying ouput in JSP

Hi im doing project using jsp files.In part of my project there is vote page and vote result page.
my vote_page.jsp
<%@ page import="java.util.*" %>
<%@ page import="java.sql.*" %>
<%@ page import="java.text.*" %>
<%@ page import="java.sql.Date" %>
<%@ page language = "java" %>
<%! int ctr=0;%>
<%! String[] songs=new String[10];%>
<%
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection connect;
connect=DriverManager.getConnection("jdbc:odbc:RegisterDataSource");
Statement state;
state = connect.createStatement();
String strQuery1 = "SELECT title FROM ItemEJBTable";
String str;
ResultSet result1 = state.executeQuery(strQuery1);
while(result1.next())
songs[ctr]=result1.getString("title");
ctr++;
connect.close();
catch(Exception e)
%>
<form method="GET" action="http://localhost:8000/Music/Vote_result_page.jsp">
<p align="center">
<font><b><u>Vote for your favorite song</u></b></font></p>
<font><b>       Songs</b></font>
<font> </font> 
<select size="1" name="Song1">
<%
for(ctr=0;ctr<songs.length;ctr++){
%>
<option>
<% out.println(songs[ctr]);}%>
</option>
</select></td>
</tr>
</table>
<input type="submit" value="Vote" name="submit">and my vote_result_page.jsp
<%@ page import="java.util.*" %>
<%@ page import="java.sql.*" %>
<%@ page import="java.text.*" %>
<%@ page language = "java" %>
<%! int voteNum=0; %>
<%! String selSong=new String();
%>
<% selSong=request.getParameter("Song1");
out.println(selSong);
String selSong1 = selSong.trim().toString();
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection connect;
connect=DriverManager.getConnection("jdbc:odbc:RegisterDataSource");
Statement state,state2;
ResultSet result1;
state = connect.createStatement();
state2 = connect.createStatement();
String strQuery1 = "update Vote_Info set Number_votes=Number_votes+1
where itemCode=(select itemCode from ItemEJBTable where title='"+selSong+"')";
state.executeUpdate(strQuery1);
String strQuery2="select Number_votes from Vote_Info where itemCode =
(select itemCode from ItemEJBTable where title='"+selSong1+"')";
result1=state2.executeQuery(strQuery2);
while(result1.next())
voteNum=result1.getInt("NumberVotes");
out.println(selSong+" got "+voteNum+" votes");
connect.close();
voteNum=voteNum+1;
catch(Exception e)
%>
<td width="82%" valign="top">
<!--Display the number of people who have voted for the song-->
<p align="left"><font face="Arial" size="3" color="#800000">
<b><u>You voted for the song:</u></b></font>
<p align="left"><font face="Arial" size="3" color="#800000">
<b><%=request.getParameter("Song1")%>
</b></font></p>
<p align="left"><%= voteNum %> <font face="Arial" size="3" color="#800000">
people have voted for this song so far.</font></p>
<input type="submit" value="OK" name="submit">When i select song_no_1 and click on vote button on vote_page.jsp it directs to vote result page and displays that
1 person has voted for this song and this vote is not updating on table. When i go again to vote page and vote on song_no_2 it says that "2 person have voted this song" even if it is not voted before.
I dont no where the problem occurs pls help me for this.

sorry for double posting because i didnt got reply from first one so i thought that nobody have looked on that topic that's why i done this.

Similar Messages

  • My performance is very slow when I run graphs. How do I increase the speed at which I can do other things while the data is being updated and displayed on the graphs?

    I am doing an an aquisition and displaying the data on graphs. When I run the program it is slow. I think because I have the number of scans to read associated with my scan rate. It takes the number of seconds I want to display on the chart times the scan rate and feeds that into the number of samples to read at a time from the AI read. The problem is that it stalls until the data points are aquired and displayed so I cannot click or change values on the front panel until the updates occur on the graph. What can I do to be able to help this?

    On Fri, 15 Aug 2003 11:55:03 -0500 (CDT), HAL wrote:
    >My performance is very slow when I run graphs. How do I increase the
    >speed at which I can do other things while the data is being updated
    >and displayed on the graphs?
    >
    >I am doing an an aquisition and displaying the data on graphs. When I
    >run the program it is slow. I think because I have the number of
    >scans to read associated with my scan rate. It takes the number of
    >seconds I want to display on the chart times the scan rate and feeds
    >that into the number of samples to read at a time from the AI read.
    >The problem is that it stalls until the data points are aquired and
    >displayed so I cannot click or change values on the front panel until
    >the updates occur on the graph. What can I do to be a
    ble to help
    >this?
    It may also be your graphics card. LabVIEW can max the CPU and you
    screen may not be refreshing very fast.
    --Ray
    "There are very few problems that cannot be solved by
    orders ending with 'or die.' " -Alistair J.R Young

  • Problem in Retrieve Image from DB and display in the JSP page

    Hi All,
    I did one JSP Program for retriveing image from DB and display in the JSP Page. But when i run this i m getting "String Value" output. Here i have given my Program and the output. Please any one help to this issue.
    Database Used : MS Access
    DSN Name : image
    Table Name: image
    Image Format: bmp
    Output : 1973956
    Sample Program:_
    <%@ page contentType="text/html;charset=windows-1252"%>
    <%@ page import="java.io.*" %>
    <%
         try{
              Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
              Connection conn = DriverManager.getConnection("jdbc:odbc:image");
              Statement st = conn.createStatement();
              ResultSet rs = st.executeQuery("SELECT images FROM image");
              String imgLen="";
              if(rs.next()){
                   imgLen = rs.getString(1);
                   out.println(imgLen.length());
              if(rs.next()){
                   int len = imgLen.length();
                   byte [] rb = new byte[len];
                   InputStream readImg = rs.getBinaryStream(1);
                   int index=readImg.read(rb, 0, len);
                   System.out.println("index"+index);
                   st.close();
                   response.reset();
                   response.setContentType("image/jpg");
                   response.getOutputStream().write(rb,0,len);
                   response.getOutputStream().flush();
         }catch(Exception ee){
              out.println(ee);
    %>
    Thanks,
    Senthilkumar S

    vishruta wrote:
    <%
    %>Using scriptlets is asking for trouble. Java code belongs in Java classes. Use a Servlet.
                   out.println(imgLen.length());Your JSP was supposed to write an image to the output and you wrote some irrelevant strings to the output before? This will corrupt the image. It's like opening the image in a text editor and adding some characters before to it.
                   byte [] rb = new byte[len];Memory hogging. Don't do that.
              out.println(ee);You should be throwing exceptions and at least printing its trace, not sending its toString() to the output.
    You may find this article useful to get an idea how this kind of stuff ought to work: [http://balusc.blogspot.com/2007/04/imageservlet.html].

  • TS3694 I was just updating my iphone and seen a massage that there is an error in updating and iphone is collapse showing only data card and iphone picture on screen

    I was updating my iphone and seen a massage there is an error in updating and after  switching from computer iphone is not restarting showing a picture of
    data cord and itunes.
    now how to resolve the problem.

    This will help
    plug into iTunes and see here
    http://support.apple.com/kb/HT1808

  • Reading a unicode file and displaying it on jsp !!!!!

    I've one file that consists of unicode character. I've to read it and display it on the jsp page. I'm able to display it other contents but for unicode i'm unable to display it properly. Could anyone help me how to achieve this problem.....
    in advance thanks a lot...............

    Read this.

  • ITunes errors - corrupted updates and error 14

    So I'm trying to update my iPad mini 1G from 7.1.1 to 7.1.2 but iTunes cannot download the update firmware without corrupting the download. I tried 14 other ipsws from other websites and iTunes will either hang during the update (30+ min) or when the progress bar reaches the end iTunes will give me error 14. I've tried looking in the forums but nothing helps, I've reinstalled iTunes on my Mac, I've used three different cables to fix error 14: nothing works. Here are my specs:
    OS X 10.9.3 (Mavericks)
    iTunes 11.2.2 (3)
    iPad Mini 1G 7.1.1

    Hi there CpuNerd,
    It looks like you have already tried a few things, but you may still find these resources helpful. The article below has troubleshooting for the specific error you are receiving.
    Resolve iOS update and restore errors
    http://support.apple.com/kb/TS3694
    Check your USB connections
    Related errors: 13, 14, 1600, 1601, 1602, 1603, 1604, 1611, 1643-1650, 2000, 2001, 2002, 2005, 2006, 2009, 4005, 4013, 4014, or “invalid response."
    If the USB connection between your device and computer is interrupted, you may be unable to update or restore.
    To narrow down the issue, you can also change up your hardware:
    Use the USB cable that came with your device, or a different Apple USB cable.
    Plug your cable into a different USB port directly on your computer. Don't plug it into your keyboard.
    Try a different computer.
    If necessary, resolve any further issues with the USB connection, then with your security software.
    If you're still seeing the error message, check for hardware issues by following the next section.
    Additionally, please keep in mind that the only supported methods of updating iOS devices are outlined in the article below. You may want to try performing an Over the Air update if iTunes is giving you trouble.
    Update your iPhone, iPad, or iPod touch
    http://support.apple.com/kb/ht4623
    Hope that helps,
    -Griff W.

  • Audio buzz and video cut-out caused by volume shadow service errors during updates and other services that create shadow copies

    I have this issue and see throughout the Internet that my problem is shared by large numbers of other Windows 7 users, and a few Windows 8 users.
    I also see that Microsoft has not addressed the issue.
    I've been troubleshooting the problem for 13 months and across 3 separate hard drives on 2 separate computers, with the help of tech escalation from both Carbonite and Dell (whom I wanted to eliminate as causes, and who have been kind enough to assist even
    after being eliminated as causes because they evidently care about customer service).
    Over 13 months we have run system diagnostics, reinstalls and repairs to no avail.  We have been able to reproduce the event in the absence of every attached device, every installed program, every subscribed service, and every hardware type and configuration. 
    We have visited chat rooms showing that this is a widespread problem (e.g., http://superuser.com/questions/630033/audio-video-glitch-when-shadow-copy-service-starts), and that even professional server administrators simply consign themselves to VSS being "the
    bane of backup software" (http://community.spiceworks.com/topic/229743-problem-with-vss-writer-system-writer-timed-out).
    Yet regardless of the computer or the configuration, the problem persists.  It causes characteristic and alarming disk write error and memory spikes on the Resource Monitor that can be traced to huge numbers on the System 4 and VSSVC.exe processes, occurring
    every time the Volume Shadow Copy Service and Application Experience create a restore point during an automatic update of Adobe, antivirus, etc.; and one can even provoke an event simply by manually creating a restore point, which has the bonus of triggering
    an 8220 notice that the Volume Shadow Service has run out of time while deleting files.  And the only advice I've seen from MS is that this is a "normal condition."
    It is not normal to be unable to enjoy audio and video.  And it is certainly not normal for one's PC to continually degrade with every update until it becomes unable to update and must be replaced. 
    I am on my 3rd computer with this problem (different type and configuration each time), and Dell has offered me an upgrade to Windows 8 in the hopes that the problem will not recur there.  But I see from Microsoft's tech chat that Windows 8 users are reporting
    the problem as well (http://answers.microsoft.com/en-us/windows/forum/windows_8-pictures/after-upgrading-to-windows-8-pro-there-is-an/813432c2-14f1-463f-bba3-ad322ceb6e00).
    Please, please post a real answer to this problem.  Thank you.

    Hi,
    Above all I understand the frustration as a same issue persists for a very long time.
    At first I'm thinking if it is directly related to the application CrashPlan some customers mentioned in one of the threads you provided. However I then noticed that you said it could be also reproduced by creating a System Restore point.
    Currently I cannot find a Windows 7 system so I used a Windows 8.1 laptop (also Dell) for testing.
    I tried to play an online video and also a local video with creating a restore point in the middle. However I failed to reproduce the same behavior. 
    The following screenshot was captured in second test (play a local video):
    I cannot confirm if it is because we have a large physical memory (8GB), or Windows 8.1 resolved this issue. From the screenshot, memory is not spiked (actually it is almost not changed).
    So in current situation you can test to enlarge the size of physical memory (and virtual memory) for test if available. And as Dell provided a Windows 8 system, you can try it before and after installing Windows 8.1.
    As a support engineer I also hope to help fix the issue or at least find out the cause. Later I will try to find a Windows 7 system for testing as well. 
    In addition, please understand that as the issue occurs mostly in Windows 7, though it seems related to VSS, it is still a Windows client system issue. So you can post the question to Windows 7 forum for further information. Here is the link:
    http://social.technet.microsoft.com/Forums/en-US/category/w7itpro/
    Please remember to mark the replies as answers if they help and un-mark them if they provide no help. If you have feedback for TechNet Support, contact [email protected]

  • Latest update and display changes

    after the latest update my display changed to higher resolution and when I go inot the preference pane I only show two available resolutions.
    What can I do to fix this
    Thank you for any help

    I tried adjusting the value of layout.css.devPixelsPerPx but that did not help. The only thing that temporarily fixed my display issues was to close Firefox- at that point the screen blacked out and reappeared in full view. As soon as I open Firefox the screen blacks out and reappears showing only a portion of my desktop and all the icons not visible are no longer clickable because the mouse cursor can't reach them.

  • Handle exception on server side and display a customized jsp error page

    Hi,
    I am developing a java/j2EE web application using servlet, jsp, ejb3 with JBOSS and ECLIPSE.
    Two cases can occur on the server side :
    1) either I have not an expected result in a method and in this case I want to display an error page (a JSP page I suppose) with a personnalized error message
    2) or I have an exception thrown and I want to display the exception message in the former JSP page
    I don't know how to cope with this problem of personnalized error message (or the message of a thrown exception) with a JSP page.
    Does anybody can help me ? Thank you
    Edited by: xflamant on Jun 20, 2009 10:51 AM

    For the case of an unknown Error, simply use a default error page.
    The redirection to this page can be accomplished by inserting folowing code into your web.xml:
         <error-page>
            <exception-type>java.lang.Throwable</exception-type>
            <location>/WEB-INF/jsp/error.jsp</location>       
        </error-page>Known exception can be caught via a try-catch block.
    Then simply dispatch to the page you want displayed an add an attribute containing the error message to the response object.
    This attribute can then be used in the target page to diplay the error.

  • Catch exception in servlet and display it in jsp

    I'm trying to catch an exception of any type in a servlet and make a jsp page handle it (display the error message). How can I pass that exception from the servlet to the jsp page?
    Thank you

    I'm trying to catch an exception of any type in a
    servlet and make a jsp page handle it (display the
    error message). How can I pass that exception from the
    servlet to the jsp page?
    Thank you In your servlet:
    try
    catch (Throwable t)
    session.putValue("ErrorMessage", t.toString());
    response.sendRedirect("/Error.jsp");
    return;
    }In Error.jsp:
    <%
    String errorMessage = (String)session.getValue("ErrorMessage");
    %>
    <html>
    <%= errorMessage %>
    </html>HTH

  • How to get value stored in  javascript function and display in a JSP

    i am doing a questionaire which is for user to input data in every question, After user input the data, a javascript function will be called to do some score calculation. Since each question will carry its final score after the calculation by the javascript function, so i use an array to store those scores and then display those scores in the same page.
    However, i have to make a confirmation page to display both data and calculated score in another jsp, i only know how to display the data as it is a textfield that i can get the value by "request.getParameter("textfield1"); but i dun know how to get those scores as they are stored in an array in the javascript function, what way i can do??

    thank you for all your help!
    I have chosen to set the score value to the hidden field when every time run the function
    <script language="javascript">
    function cal(index){
    var thisForm = document.MC;
    thisForm.score1.value=score[index];//set value to the hidden field     
    </script>
    <input type="hidden" name="score1" value="">
    <input type="hidden" name="score2" value="">
    <input type="hidden" name="score3" value="">
    The function will calculate only one score when every time being called. So that i can only assign one score to one hidden value at a time.
    e.g, assign score[1] to thisForm.score1.value
    assign score[2] to thisForm.score2.value
    assign score[3] to thisForm.score3.value
    how can i do this??

  • Icon info doesn't update, and display issues

    On my desktop I have my icons set to show information such as drivespace under them. When I empty the trashcan the information doesn't update on the icon, but it does in the finder (finder shows 12gigs, but icon still says 3.4gigs). Is this a common bug or is does it not do this on anyone elses computer?
    Also I'm running an external display and sometimes I notice that my primary display looks really bright, when I try to change the color profile it says something about not being able to find the primary display or something like that. This only happens once in a while when I have my external display plugged in. I was running the ATI drivers, but I think the last apple update replaced them with the Apple drivers.
    Any help or comments are appreciated

    you specified the delay for timer"1000" but not the repeat amount.
    your if statement will only run once unless you put it inside the onTimer function.
    the new Date() statement sould be outside the onTimer function

  • Error when updating to display artwork!!

    I am having a problem with the artwork displaying on my iPod. I go into iTunes and go under iPod options and UNCHECK the box to display the artwork on my iPod. Then click okay. Then, go back into it and CHECK the box TO display the artwork and I get an error; "..Unknown Error occurred (-50)". And yes I have pressed the center button on my iPod to scroll through the different things. And I have restarted the program and computer. I've tried other different things but it all ends up to this error. Can some one please help me

    Okay I've tried solving this issue all day and nothing had worked.

  • IPhoto had an error when updating and now says: "Use the Purchases page to try again."

         Before I went to school yesterday morning I started the iPhoto update so when I got back it would be done. So I looked to see if the update was finshed and it said: "An error haas occured" next to the update button. So I hit update again and it came up with what you see in the picture below.
    So I went to the purchase tab and tried again and the same thing happened again! What do I do? Thank you!

    Hi there!
    Did you get any explanation for that "8.8.8.8-solution"? Very strange but it seemed to work with me but only for some apps.
    My problem doesn't look the same though. I managed to download all big apps like iPhoto and Xcode but the small ones never get installed properly. I see they are being downloaded but after that I get "Installed" button and a message to use purchases tab again and the app is not installed on Applications folder.
    On ML 10.8.0 Mac App Store was downloading and re-downloading these small apps adn the only way I found to solve this was pause the download, add the 8.8.8.8 to DNS and resume. I worked for some apps.
    On ML 10.8.2 Mac App Store behavior is a little different, I only get "Installed" button shortly after having hit "Install" and cannot even pause. After reboot I see an error message in red "An error has ocurred".
    This is not happenning on Snow Leopard, what the heck have they done??
    I tried all suggestions, reset Mac App Store, delete cache folder, I don't have any anti-virus running,
    What's happenning? This is reallly annoying...
    L.

  • Error when updating and restoring iPhone6

    An error #53 occurred when updating my new iphone6.  now it won't update/restore.  It is locked at the iTunes plug in screen.

    Connect it to your computer with the USB cable and it should appear in iTunes as a phone in Recovery Mode. If it doesn't see this Apple Knowledge Base article: Recovery Mode

Maybe you are looking for