How to create a current year to 1900 select box in JSP

hey guys,

i got one simple logic to create a current year to 1900 select box. lets go for coding.


Date dNow = new Date( );    
SimpleDateFormat = new SimpleDateFormat ("yyyy");    
String year = ft.format(dNow);    
int foo = Integer.parseInt(year);    
while(foo > 1989)

<option value=”<%=foo%>”><%=foo%></option>



List of file with Delete option in JSP

ya , here is improved version of previous post. you can view all files within a particular directory as well as delete any file.

specially this kind of requirements came when i was working in Advertisement Management Module. so there admin can view all advertisement images which he uploaded previously and he can also able to delete from directory. so he can able to manage disk size.

k lets go for coding.

oky so first i need to fetch all images from directory with delete button. i m putting filename in button id value so i can easily recognize that for which file user pressing delete button. and once i’will get filename then rest of coding flow is very simple.. i will pass that filename to delete.jsp file and there i will write logic to delete that file.


JavaScript Function


and bellow screenshot is for listing of files from directory.


and now bellow jsp file show you delete function for that file

<%@ page import="*" %>
String id = request.getParameter("id"); 
File file = new File("C:\\Users\\LYMAN\\Documents\\NetBeansProjects\\WebApplication2\\web\\upload\\"+id+""); 
out.println("file deleted successfully");
else { 
	out.println("failed to perform delete operation"); 

hope you like this post.. 🙂

Listing files from Directory in JSP

hello guys,

today i gonna share some interesting stuff in JSP (Java Server Pages). so this post is regarding display list of all files from particular directory using jsp.

so let’s go for coding.

<%@ page import="*" %>
String file = application.getRealPath("/upload");
File f = new File(file);
String [] fileNames = f.list();
File [] fileObjects= f.listFiles();
for (int i = 0; i < fileObjects.length; i++) {
    String fname = file+fileNames[i];

you can insert some html code in jsp file to display it in proper format. you can also you
<a HREF=”<%= “upload/”+fileNames[i] %>”><%= fileNames[i] %></a> to put hyperlink on file so user can also view that file.

hope you enjoy this post.! 🙂