Results 1 to 5 of 5

Thread: Refresh after upload an image in jsp

  1. #1
    Join Date
    Nov 2009
    Posts
    712

    Refresh after upload an image in jsp

    Hello, I am creating one of the project in java with the help of JSP. And now I want to Refresh the page when upload of an image in jsp page gets completed. If anyone of you know how to achieve it, then please provide me help regarding it. I am not able to get solution for it. So, if you are having solution for it, then please provide help to me.

  2. #2
    Join Date
    May 2008
    Posts
    2,389

    Re: Refresh after upload an image in jsp

    Hello, if you make use of the servlet then you can solve your problem by simply making use of the code below:
    Code:
    DataOutput Out = new DataOutputStream (res.getOutputStream ());
    res.setContentType ( "image / jpeg");
    String img = request.getParameter ( "imageName");
    File filename = null;
    FileInputStream in = null;
    String filenamePath = img.replace ("/", "\ \");
    filename = new File (filenamePath);
    if (File.Exists ())
    return;
    in = new FileInputStream (filename);
    res.setContentLength ((int) filename.length ());
    byte value [] = new byte [4096];
    int number;
    
    while ((number = in.read (value))! = -1)
    {
    Out.Write (value, 0, number);
    }
    
    in.close ();

  3. #3
    Join Date
    Feb 2008
    Posts
    1,852

    Re: Refresh after upload an image in jsp

    Hello, when I was creating program for refreshing the code I have make use of the code below:
    Code:
    while (resultSet.next())
    {
    InputStream IStr =resultSet.getBinaryStream(2);
    int c=0;
    byte[] arr = new byte[4096];
    int size=0;
    res.reset();
    res.setContentType("image/jpeg");
    res.setHeader("Content-Disposition","filename=logo.jpg");
    while ((c = IStr.read(arr)) != -1)
    {
    res.getOutputStream().write(arr,0,c);
    
    }
    System.out.println("Blob retrieved");
    }

  4. #4
    Join Date
    Oct 2005
    Posts
    2,393

    Re: Refresh after upload an image in jsp

    Hello, I am not able to get your problem properly. If you provide me in details about your problem then I can able to solve it. I want the details below:
    • Is it as home page of your application.
    • To customize the logo there are you using the link of the any other page or you are making use of the hidden form which will appear in your home page.
    • Are you passing any new window for the popup.

  5. #5
    Join Date
    Jan 2008
    Posts
    1,521

    Re: Refresh after upload an image in jsp

    Hello, I think you must need to make use of the code below for getting your refresh of page after uploading an image in jsp:

    Code:
    <% @ Page import = "java.sql .*;"%>
    <%
    Connection con = null;
    RequestDispatcher requestD;
    
    try
    {
    pass String = (String) session.getAttribute ( "pass");
    String lgin = "*****";
    String reqpass = "******";
    String url = "jdbc: mysql ://*******/ schneider_final";
    Class.forName ( "com.mysql.jdbc.Driver"). NewInstance ();
    con = DriverManager.getConnection (url, lgin, reqpass);
    java.sql.Statement statement = con.createStatement ();
    java.sql.ResultSet rs = statement.executeQuery ( "select * from users where pass =" + pass);
    
    if (rs.first ())
    {
    String logo = rs.getString ( "logo");
    
    if (logo! = null)
    {
    out.println ( "<img src=\""+request.getContextPath()+"/SrvShowLogo?imageName="+logo+"\">");
    out.println ( "</ div>");
    }
    }
    rs.close ();
    statement.close ();
    }
    catch (Exception e)
    { }
    %>
    <br>

Similar Threads

  1. Using a Custom System Image, Refresh Windows 8
    By Faraji in forum Tips & Tweaks
    Replies: 1
    Last Post: 24-08-2012, 06:10 PM
  2. How to refresh an image control in Silverlight
    By NAKKIRAN in forum Windows Software
    Replies: 4
    Last Post: 13-12-2010, 07:11 PM
  3. How to upload my profile image on Facebook
    By Daniel23 in forum Technology & Internet
    Replies: 3
    Last Post: 20-11-2009, 12:24 AM
  4. Html replace browse image upload
    By Brunoz in forum Software Development
    Replies: 3
    Last Post: 04-08-2009, 03:24 PM
  5. Upload image randomly with JavaScript Page
    By Zubeen in forum Software Development
    Replies: 3
    Last Post: 25-02-2009, 02:54 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,711,618,498.14299 seconds with 17 queries