943,866 Members | Top Members by Rank

Ad:
  • JSP Discussion Thread
  • Marked Solved
  • Views: 6206
  • JSP RSS
Dec 19th, 2008
0

How to delete files using jsp?

Expand Post »
I am just wondering if i want to delete a file using coding how can i do it using jsp?
Example i have a file name pig.jpg in my root folder and I wish to delete this file as i no longer use this any more how can i do this using coding?
Similar Threads
Reputation Points: 10
Solved Threads: 1
Light Poster
dreamer14 is offline Offline
31 posts
since Sep 2008
Dec 19th, 2008
0

Re: How to delete files using jsp?

You should create some sort of view (in JSP) where user can browse the whole web folder structure something like this
Click image for larger version

Name:	folder_view.png
Views:	174
Size:	4.9 KB
ID:	8581

with some buttons on the bottom (I cut that off image would be to big)
Then let the user mark the file/folders for deleting. User hit the delete button, JSP send names of selected files for deletion together with current folder level to servlet, servlet does his deleting job and returns updated view in JSP of current folder level with some notifications message such as "file deleted", "unable to delete"
Moderator
Featured Poster
Reputation Points: 2786
Solved Threads: 873
Code tags enforcer
peter_budo is offline Offline
6,656 posts
since Dec 2004
Dec 19th, 2008
0

Re: How to delete files using jsp?

I know how to do most of it except the
"servlet does his deleting job".
Can i have a example for this?
Is it possible not to use a servlet but just coding ?
I am terribly bad at servlet.
Reputation Points: 10
Solved Threads: 1
Light Poster
dreamer14 is offline Offline
31 posts
since Sep 2008
Dec 19th, 2008
0

Re: How to delete files using jsp?

Servlets are essential in Java web development so you will not escape them if you considering job related to Java development. Sooner or later you will have to face your enemy and I would say do it now, because now you will learn easier then later to try put a side your previous bad habits.
If you can explain where you having difficulties with servlet implementation we may be able to help you.
Moderator
Featured Poster
Reputation Points: 2786
Solved Threads: 873
Code tags enforcer
peter_budo is offline Offline
6,656 posts
since Dec 2004
Dec 19th, 2008
0

Re: How to delete files using jsp?

i hae only learn servlet for a few days so i have no idea where to start. Any reali basic guide to teach the baisc?
Reputation Points: 10
Solved Threads: 1
Light Poster
dreamer14 is offline Offline
31 posts
since Sep 2008
Dec 19th, 2008
0

Re: How to delete files using jsp?

General resource The Java EE 5 Tutorial, Beginning and Intermediate-Level Servlet, JSP, and JDBC Tutorials plus I enjoyed Java How to Program, 6th edition from Deitel
Moderator
Featured Poster
Reputation Points: 2786
Solved Threads: 873
Code tags enforcer
peter_budo is offline Offline
6,656 posts
since Dec 2004
Dec 29th, 2008
0

Re: How to delete files using jsp?

Deleting file JSP code

<%
File f=new File("c:\\imagesFolder\\pig.jpg");

f.delete();

%>

In linux machine you have to use different separator

Search platform Independent separator for operating system
Reputation Points: 9
Solved Threads: 1
Newbie Poster
rockonjava is offline Offline
5 posts
since Dec 2008
Dec 29th, 2008
0

Re: How to delete files using jsp?

Click to Expand / Collapse  Quote originally posted by rockonjava ...
Deleting file JSP code

<%
File f=new File("c:\\imagesFolder\\pig.jpg");

f.delete();

%>

In linux machine you have to use different separator

Search platform Independent separator for operating system
I'm trying to show dreamer14 how to do things the correct way and you just drop in some scriplet solution? Also you made few other post where you even suggested to do DB connectivity from JSP, I do not think they will be overly popular.
Not that I did not use scriplets before too, but since then I made some progress in this field
Moderator
Featured Poster
Reputation Points: 2786
Solved Threads: 873
Code tags enforcer
peter_budo is offline Offline
6,656 posts
since Dec 2004

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in JSP Forum Timeline: JAVA TOMCAT "HTTP Status 500 error" help
Next Thread in JSP Forum Timeline: Error while accessing data from other drive.





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC