Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

check File Existence and display alert message

 
Rohit Kumar
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 ]
 
sudhir nim
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.
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • 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: 42967
73
  • 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.
 
Senthil Kumar
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic