Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Register Tags Active Topics RSS Search Mark Forums Read

Sponsored Links



Refresh after upload an image in jsp

Software Development


Reply
 
Thread Tools Search this Thread
  #1  
Old 11-02-2010
Member
 
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.

Reply With Quote
  #2  
Old 11-02-2010
Member
 
Join Date: May 2008
Posts: 2,373
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 ();
Reply With Quote
  #3  
Old 11-02-2010
Member
 
Join Date: Feb 2008
Posts: 1,842
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");
}
Reply With Quote
  #4  
Old 11-02-2010
Member
 
Join Date: Oct 2005
Posts: 2,385
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.
Reply With Quote
  #5  
Old 11-02-2010
Member
 
Join Date: Jan 2008
Posts: 1,507
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>
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Refresh after upload an image in jsp"
Thread Thread Starter Forum Replies Last Post
Using a Custom System Image, Refresh Windows 8 Faraji Tips & Tweaks 1 24-08-2012 06:10 PM
How to refresh an image control in Silverlight NAKKIRAN Windows Software 4 13-12-2010 06:11 PM
How to upload my profile image on Facebook Daniel23 Technology & Internet 3 19-11-2009 11:24 PM
Html replace browse image upload Brunoz Software Development 3 04-08-2009 03:24 PM
Upload image randomly with JavaScript Page Zubeen Software Development 3 25-02-2009 01:54 PM


All times are GMT +5.5. The time now is 02:36 PM.