Tech
Forums
Jobs
Books
Events
Interviews
Live
More
Learn
Training
Career
Members
Videos
News
Blogs
Login
Sign Up
Ask Question
0
Reply
Error in file fetch from table in jsp
Venkatesh K H
Sep 5 2017 9:14 AM
228
Reply
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();
}
%>
Upload Source Code
Select only zip and rar file.
Post
Reset
Cancel
Answers (
0
)
Next Recommended Forum
How to make photo gallery using jsp mysql
Count Checked checkboxes and add to hidden field in HTML