Good day everyone Please i needs help.This code was used to fetch information from database.
whenever a correct id at BEANS.JSP is entered ,it will fetch every information from that row.
But the problem am having is that it will retrieve every information on that row but the Image cannot
be retrieve instead it will retrieve image link.Please how do i solve this problem using JSP only.
I'm not sure if I understand what you are trying to say. But that code up there looks like you're actually getting an image out of the database -- not a URL pointing to the image, but the actual image itself -- and then trying to send it to the client in a place where HTML requires you to put a URL pointing to the image.
Well, you can't do that. You are going to have to produce HTML which contains a URL which points to the image. Obviously the URL can't point to the database column, so it will have to point to a servlet which returns the image. It would have to have a parameter which identifies which image to return, and the servlet would have to set up the response so that the browser knew there was an image being sent, not HTML. Which is why it should be a servlet and not a JSP which returns the image.
Actually most of that code should be in a servlet, not in a JSP. But that's a separate topic. And your JDBC code should be using a PreparedStatement instead of the unreliable method of creating a query by concatenating strings, but that's another separate topic.
Joined: Mar 04, 2010
thanks for your reply i appreciate your help
Okay i develope this servlet code it retrieves all the informations on every row when a correct ID corresponding to that row is entered at
BEAN.JSP. Let assume that i have 2 rows in my database with ID 1,2 etc when i enter ID 1 i will get every information in that row
it works,but if enter ID 2 at BEANS.Jsp, before it will fetch that data at row 2 corresponding to ID 2 i entered it will require me to manually go to RICE.JSP and change the ID values eg to 2 ie id=2 otherwise it will keep on fetching all data at row 1.
Please sir how do i circumvent this problem so that any id i entered it will retrieve that row automatically with requiring me to be edicting the id manually eg id=1,id=2 and so on.
Good day everyone, please when i run this code it keeps on telling me the error below whereas i have commons-upload.jar and common-io.jar file in my both directory TOMCAT/lib and FREA/WEB-INF/lib.
but if run servlet it will run and no such error will be displayed.Is there any other dependecy jar file i need to install so that this error below will stop occuring
thanks and have a wonderful day
It seems you're not trying very hard to debug this problem. In looking at this error, it's telling you that you have a FileNotFoundException when trying to open a FileOutputStream from within a JSP page. Doesn't that give you any clue at all about where the problem might be? Does your JSP page attempt to open a FileOutputStream anywhere? If so, what is the file name you're passing to it? Is the file name valid?
By the way, it seemed originally you were trying to extract an image from the database and display it in the browser, but now you seem to be attempting to upload a file to the server. What's the deal? Has the problem changed? Perhaps you should create a new topic for the new problem.
Finally, you really, really shouldn't be doing any Java programming in the JSP page itself. The JSP page should be used to gather user input and display results. The application logic should be in (or behind) a Servlet. Have your JSP page just gather the user input and POST to a Servlet, where you can do all your application logic. If you continue to try to execute your application logic in the JSP page, you're going to have a lot of difficulty.
Joined: Mar 04, 2010
Thanks very much, the problem has being resolved
Mark E Hansen
Joined: Apr 01, 2009
Perhaps you could share the solution with everyone?