Win a copy of Learning Regular Expressions this week in the General Computing forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

check File Existence and display alert message  RSS feed

 
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have a servlet which uploads file to server. Below is my code and is working file. Now, I want to check if the file uploading by the user is already exists. If so , I have to display a message to user "The file you are trying to upload already exists. Do you want to overwrite" with YES or NO actions.

How can I display this alert message from user.



Can anyone suggest me on this?
[ October 30, 2007: Message edited by: Ben Souther ]
 
Ranch Hand
Posts: 212
Eclipse IDE Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can render a new page and display the message, or you can use ajax to upload file, and if file exists on the server display an alert using ajax.
 
Rancher
Posts: 42975
76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rendering a new page informing the user is the way to go.

AJAX has no concept of files, and so can't be used for the upload.
 
sudhir nim
Ranch Hand
Posts: 212
Eclipse IDE Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


AJAX has no concept of files, and so can't be used for the upload.[/QB]



Why not?
You can use ajax to upload files. do some googling you will find read made code.
 
Ulf Dittmer
Rancher
Posts: 42975
76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by sudhir nim:
Why not?
You can use ajax to upload files. do some googling you will find read made code.


AJAX can send data to the server, but it can't upload files because JavaScript has no access to the client file system.
 
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rohit,
You can try setting a request atribute in the servlet once you find the file already exists in the location.
1.In the JSP write a scriplet for getting the attribute value and assign it to variable declared in the scriptlet.
2.Now declare a variable in the Javascript and assign scriplet variable's value to this script variable.
3.You have to write an ONLOAD event Handler.
In that function,check the javascript variable and display the alert.
I think this will work.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!