473,386 Members | 1,804 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Slideshow for the images

Hai everyone,

I need to provide the slideshow for the images.

I have upload the images into database. Then i will retrive all the images from the database and provide the slideshow for those images. I have try with the following jsp code.

Expand|Select|Wrap|Line Numbers
  1. <%@ page language="java" %>
  2. <%@ page import="java.sql.*"%>
  3. <%@ page import="java.sql.Connection.*"%>
  4. <%@ page import="java.awt.image.*"%>
  5. <%@ page import="java.io.*"%>
  6. <%@ page import="java.io.File"%>
  7. <%@ page import="javax.imageio.ImageIO"%>
  8. <%@ page import="java.awt.image.BufferedImage,java.util.*"%>
  9. <%@ page import="java.awt.*"%>
  10. <%
  11. java.util.Vector images = (java.util.Vector)request.getAttribute("images");
  12. %>
  13. <html>
  14. <head>
  15. <title>JSP Page</title>
  16. <SCRIPT LANGUAGE="JavaScript">
  17. <!-- Begin
  18. var Onerotate_delay = 2000; // delay in milliseconds (5000 = 5 secs)
  19. Onecurrent = 0;
  20. var OneLinks = new Array(3);
  21. OneLinks[0] = "http://www.freewarejava.com";
  22. OneLinks[1] = "http://www.javascriptkit.com";
  23. OneLinks[2] = "http://www.dynamicdrive.com";
  24. function Onenext() {
  25. if (document.Oneslideform.Oneslide[Onecurrent+1]) {
  26. document.images.Oneshow.src = document.Oneslideform.Oneslide[Onecurrent+1].value;
  27. document.Oneslideform.Oneslide.selectedIndex = ++Onecurrent;
  28. }
  29. else Onefirst();
  30. }
  31. function Oneprevious() {
  32. if (Onecurrent-1 >= 0) {
  33. document.images.Oneshow.src = document.Oneslideform.Oneslide[Onecurrent-1].value;
  34. document.Oneslideform.Oneslide.selectedIndex = --Onecurrent;
  35. }
  36. else Onelast();
  37. }
  38. function Onefirst() {
  39. Onecurrent = 0;
  40. document.images.Oneshow.src = document.Oneslideform.Oneslide[0].value;
  41. document.Oneslideform.Oneslide.selectedIndex = 0;
  42. }
  43. function Onelast() {
  44. Onecurrent = document.Oneslideform.Oneslide.length-1;
  45. document.images.Oneshow.src = document.Oneslideform.Oneslide[Onecurrent].value;
  46. document.Oneslideform.Oneslide.selectedIndex = Onecurrent;
  47. }
  48. function Oneap(text) {
  49. document.Oneslideform.Oneslidebutton.value = (text == "Stop Slideshow") ? "Start Slideshow" : "Stop Slideshow";
  50. Onerotate();
  51. }
  52. function Onechange() {
  53. Onecurrent = document.Oneslideform.Oneslide.selectedIndex;
  54. document.images.Oneshow.src = document.Oneslideform.Oneslide[Onecurrent].value;
  55. }
  56. function Onerotate() {
  57. if (document.Oneslideform.Oneslidebutton.value == "Stop Slideshow") {
  58. Onecurrent = (Onecurrent == document.Oneslideform.Oneslide.length-1) ? 0 : Onecurrent+1;
  59. document.images.Oneshow.src = document.Oneslideform.Oneslide[Onecurrent].value;
  60. document.Oneslideform.Oneslide.selectedIndex = Onecurrent;
  61. window.setTimeout("Onerotate()", Onerotate_delay);
  62. }
  63. }
  64. function Onetransport(){
  65. window.location=OneLinks[Onecurrent]
  66. }
  67. //  End -->
  68. </SCRIPT>
  69. </head>
  70. <body>
  71. <%-- <jsp:useBean id="beanInstanceName" scope="session" class="beanPackage.BeanClassName" /> --%>
  72. <%-- <jsp:getProperty name="beanInstanceName"  property="propertyName" /> --%>
  73. <TABLE border="0" cellspacing="0" cellpadding="0" align="center">
  74. <TR>
  75. <TD>
  76.     <form name="Oneslideform" >
  77.     <DIV align="center">
  78.     <TABLE width="150" border="1" cellspacing="0" cellpadding="4" bordercolor="#330099">
  79.     <TR>
  80.     <TD bgcolor="#330099">
  81.         <DIV align="center"><B><FONT color="#FFFFFF">Image Slideshow</FONT></B></DIV>
  82.     </TD>
  83.     </TR>
  84.     <TR>
  85.     <TD bgcolor="#FFFFFF">
  86.         <DIV align="center">
  87.         <img src="" width="500" height="400" name="Oneshow" border="1"/>                
  88.         </DIV>
  89.     </TD>
  90.     </TR>
  91. <%
  92. String img="";
  93. for(int i=0; i<images.size(); i++) {
  94. img=String.valueOf(images.elementAt(0));
  95. javax.servlet.http.HttpServletResponse res=null;;
  96. int returnValue = 0;
  97. Connection conn = null;
  98. Statement stmt = null;
  99. ResultSet rs = null;
  100. InputStream in = null;
  101. OutputStream os = null;
  102. Blob blob = null;
  103. String text;
  104. text=request.getParameter("text");
  105. Class.forName("com.mysql.jdbc.Driver");
  106. conn=DriverManager.getConnection("jdbc:mysql://localhost:3306/sample","root","veradis");
  107. %>
  108.     <TR>
  109.     <TD bgcolor="#330099">
  110.         <DIV align="center">
  111.         <SELECT name="Oneslide" onChange="Onechange();">
  112. <%
  113. int i=1;
  114. //String id="14";
  115. String query = "select image,type from tbl_image ";//where name ='"+images.elementAt(0)+"'"; 
  116. Statement st = conn.createStatement();
  117. rs = st.executeQuery(query);
  118. while(rs.next())
  119. {
  120.     byte[] bytearray = new byte[4096];
  121.     int size=0;
  122.     InputStream sImage;
  123.     sImage = rs.getBinaryStream(1);
  124.     response.reset();
  125.     response.setContentType(rs.getString("type"));
  126.     while((size=sImage.read(bytearray))!= -1 )
  127.     {
  128.         response.getOutputStream().write(bytearray,0,size);
  129.     }
  130.     System.out.println("HAI" + i);
  131.     i++;
  132. }
  133. if(images.size()>0) {
  134. for(int j=0;j<images.size();j++) {
  135. %>
  136.         <OPTION value="<%=response.getOutputStream()%>"><%=response.getOutputStream()%></OPTION>
  137. <%
  138. }   }
  139. %>
  140.         </SELECT>              
  141.         </DIV>
  142.     </TD>
  143.     </TR>
  144.  
  145.     <TR>
  146.     <TD bgcolor="#330099">
  147.         <DIV align="center">
  148.         <INPUT type=button onClick="Oneprevious();" value="<<" title="Previous">
  149.         <INPUT type=button name="Oneslidebutton" onClick="Oneap(this.value);" value="Start Slideshow" title="AutoPlay">
  150.         <INPUT type=button onClick="Onenext();" value=">>" title="Next">
  151.         </DIV>
  152.     </TD>
  153.     </TR>
  154.     </TABLE>
  155.     </DIV>
  156.     </form>
  157.   </TD>
  158.   </TR>
  159. </TABLE>
  160. </body>
  161. </html>
But using the above code only one image could be display. I need the slide show for all the images from the database.

And also i need to Reduce the time for upload the image and Retrive the image from database. When we upload the large size of image, that will take more time. But i need to upload and Retrive those type of images with less timing.

Please help me for this.
Sep 5 '07 #1
1 3323
Hello everyone,

No one there for solve this problem.

I need it's very urgent. So please anybody can help me for this thread.

Waiting for replies

Thanks for useful replies.
Sep 10 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Tim | last post by:
Hope someone in the big wide world can help... What I want to do is have an image slideshow which automatically scrolls through a series of images very fast, then pauses when you move your mouse...
2
by: Susanna | last post by:
Hi all, I'm using the following slideshow script that I found on the web to display changing images with a crossfade effect. Eventually I will be adding many more images to the slideshow. The...
2
by: Jeannie | last post by:
I have a popup window which is a slideshow of about 7 images. When the popup window loads, the first image is present and then the viewer can select next or previous to scroll through the rest of...
8
by: drillbit_99 | last post by:
I have an HTML page of thumbnail images. Each image can begin a slideshow of the images on the page by clicking on the image. This opens another HTML page that begins the slideshow using large...
11
by: David Graham | last post by:
Hi New to javascript. I'm trying to understand how a script at a website I come across works. http://www.BRPPISAFETY.COM Nearly got it but I have changed the variable called 'crossFadeDuration'...
8
by: GabrielESandoval | last post by:
i currently use the code below to create a slideshow of images. i edited it so that its not as long. i currently have over 20 images i want to change it so that the images dont appear in the...
2
pradeepjain
by: pradeepjain | last post by:
script> // (C) 2000 www.CodeLifter.com // http://www.codelifter.com // Free for all users, but leave in this header // NS4-6,IE4-6 // Fade effect only in IE; degrades gracefully //...
3
by: Gaby Sandoval | last post by:
I have a very simple javascript slideshow. It is extremely basic (see small sample below): <script language="JavaScript1.1"> <!-- //specify interval between slide (in mili seconds) var...
1
by: maarten2002 | last post by:
Hi people, I am quite new to JS-scripting and I have a question. Finally I found a "good" slideshow which works in IE, Chrome, FF with prototype. The only thing is that I would like the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.