Jump to content

[JSP] Please solve my send.redirect("") error


Recommended Posts

Hello friends,

I have a table which contains file names. For example i have stored a file "java.pdf" in a directory called "course". The file is located here. http://www.something.com/course/java.pdf

 

Now i stored the file name in a column named "document_filename".

I stored it as "java.pdf"

 

Now if a user click the course it should rediect to view the file. I coded like this. Please correct my code.

<%@ page contentType="text/html; charset=utf-8" language="java" import="java.sql.*" %> 
<% 
try { Class.forName("com.mysql.jdbc.Driver"); 
Connection con = DriverManager.getConnection("jdbc:mysql://localhost/elearning_datasource?user=root"); 
int course_id; 
String query,query1; course_id=Integer.parseInt(request.getParameter("course_id")); 
String statement="SELECT document_filename from x_masterlistofdocuments where course_id="+course_id+""; ResultSet objRs=null; response.sendRedirect("http://www.something.com/course/%=statement%"); 
con.close(); 
} 
catch(Exception e) 
{ 
out.println("Error?"+e.getMessage()); 
} 
%>

 

I understand the error is in this line:

response.sendRedirect("http://www.something.com/course/%=statement%");

 

 

I want redirect to the file what is selected using query. Thankyou friends

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.