Venkatesh K H

Venkatesh K H

  • NA
  • 116
  • 33.1k

Error in file fetch from table in jsp

Sep 5 2017 9:14 AM
I am currently doing folder structure using jsp. Files are uploaded to the folder and saved file path and filename into the database. Fetching the file from database to the front end using jsp code. Files are displayed with a href link. But when i click on file it is not open or downloadable. When i click on file it should open. Please check what is the problem in code.
 
Note: File is in href format but not opening or downloadable in my project.  
File path saved as:  D:\\UploadedFiles\\index.html'
<%
try {
//String s3=null;
// String s2=null;
statement = connection.createStatement();
String query ="select name,file from file where category=1";
resultSet = statement.executeQuery(query);
while (resultSet.next()) {
String fname=resultSet.getString("name");
String fpath=resultSet.getString("file");%>
<li> <a target="_balnk" href="<%=fpath%>"><%=fname%></a></il>
<%
}
}
catch (Exception e) {
e.printStackTrace();
}
%>
 
 
<%
try {
//String s3=null;
// String s2=null;
statement = connection.createStatement();
String query ="select name,file from file where category=1";
resultSet = statement.executeQuery(query);
while (resultSet.next()) {
String fname=resultSet.getString("name");
String fpath=resultSet.getString("file");%>
<li> <a target="_balnk" href="<%=fpath%>"><%=fname%></a></il>
<%
}
}
catch (Exception e) {
e.printStackTrace();
}
%>