how to specify the src come in a session, java problems tips" /> how to specify the src come in a session. Get java problems tips from javaproblemstips.info" />

how to specify the src come in a session

Category: Web Develop
 
a2767
2011-06-09 02:49:45

Sponsored Links

<img src="D:\\123.jpg"/>

so that I can show on the website 123.jpg

the jpg file but if I was backstage java program that extracted from the database how to do?
I can now embed java code on the page the file from the session raised.

File file = request.getSession().getValue("imageFile");

It can also be converted into a byte File form.
but how to establish contact with the img tag it?

I do not want to use a temporary file in the form. Do not want to generate temporary files on the server, you want to turn off the IE image files with user automatically released.

Thank you!

Sponsored Links

hangkaf
2011-06-09 03:00:32

File file = request.getSession().getValue("imageFile");
request.setAttribute("imgPath",file.getAbsoluteFile());


<img src="${imgPath}"/>

I not want to use a temporary file in the form. Do not want to generate temporary files on the server does not generate files how
show it?
can generate temporary files, page cleared off the line

yzbyytt2
2011-06-09 03:12:49
src write directly on the page with pictures or servlet
chen1984612
2011-06-09 03:24:50

public void showpic(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String url = request.getParameter("url");
String suffix = request.getParameter("suffix");
response.setContentType("image/" + suffix + ";charset=GB2312");
OutputStream out = response.getOutputStream();
FileInputStream in = new FileInputStream(new File(url));
int i = 0;
byte buffer[] = new byte[8192];
while ((i = in.read(buffer, 0, buffer.length)) != -1) {
out.write(buffer, 0, i);
}
out.flush();
in.close();
in = null;
}


previously written a method that reads a file and stream output picture him as a required parameter is the absolute path of the picture and the picture of the suffix Name
yangsaikun2008
2011-06-09 03:36:06
<img src = "<% = taken out%>" />
zts123
2011-06-09 03:52:15
save relative path, take the easy
jmllpoy
2011-06-09 04:04:14

top
so you can verify code practice
caogenlongbj
2011-06-09 04:14:44

path you have found no pictures??? there should be a picture file, a file there is a path
Domain and server ip had changed since 8/23/2013. Suspend the user registration and posts for program maintenance.