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?

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

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"

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.

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.

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?

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

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.