I am a beginner in j2ee, I met a problem when retrieving an image already stored in the database. I am using Hibernate and JSP, the code I used is as follows:
/ / java code:

s.setAttribute ("photo", l.getPhoto ());  
StringTokenizer st = new StringTokenizer (s.getAttribute ("photo"). ToString (), "/");  
String text = "/";  
Object [] tab;  
tab = new String [50];  
int i = 0;  
while (st.hasMoreElements ())  
{  
tab [i] = st.nextElement ();  
i + +;  
Text = text +} tab [0] + "/" + tab [1] + "/" + tab [2] + "/" + tab [3] + "/" + tab [4]  s.setAttribute ("photo", text)

/ / display in the jsp page:
<img src = "/ web <% = s.getAttribute (" photo ")%>
the problem is that I receive the link of the image with a slash and null at the end of such link is: localhost... / web / img / image.jpg / null. Does there anything I should do?
I apologize for the translation, I'm French

Member Avatar

the problem is that I receive the link of the image with a slash and null at the end of such link is: localhost... / web / img / image.jpg / null. Does there anything I should do?

This is where I get confused when you mention the link with backslashes appearing.

I mean the main issue is retrieving the image from the database.

You can used this:

http://www.roseindia.net/jsp/retrieve-image.shtml

It has an example with code that include database code which you can fetch the image from the database.