由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Java版 - display an image from db along with other text on jsp
相关主题
Question about Model 2J2EE和未来工作问题
唉进了一家烂公司interview求助
memcachedJSF有前途吗
FrameworkServlet?JSP + Spring MVC, Newark Delaware
JSP How to Invoke the Specific version of Xerces-J现在 Java Web 开发过时了么?
哪位大牛可以总结一下各种java框架的基本思想,优于其它框架的地方以及适用范围。How to scroll an JInternalFrame
请问JSP/SERVLET和MYSQL如何实现照片上载和调用How to display .bmp image
Jsp-Mysql for multitype resources[合集] Are JSPs Dead?
相关话题的讨论汇总
话题: image话题: what话题: jsp话题: db话题: other
进入Java版参与讨论
1 (共1页)
h**d
发帖数: 474
1
I have some images saved in db using BLOB.
I need to display one image with other information using struts2 framework,
now my action has the byte array of image.
What's the easiest solution? What's the most elegant solution?
What I can think about: save it as a temp file, and show it as a link in JSP.
Thanks....
o***g
发帖数: 2784
2
没做过
应该可以写个servlet处理*.a请求,发送图片数据

JSP.

【在 h**d 的大作中提到】
: I have some images saved in db using BLOB.
: I need to display one image with other information using struts2 framework,
: now my action has the byte array of image.
: What's the easiest solution? What's the most elegant solution?
: What I can think about: save it as a temp file, and show it as a link in JSP.
: Thanks....

g*****g
发帖数: 34805
3
From browser point of view, your image is nothing more than
a link, it has to be a known extension though otherwise some browser
may not be able to render it as image.
For Spring MVC, you can map all links to some folder,
etc. /img/* to some controller, then you can write the
image back, all you need to do is set appropriate image
mime type. Sth. like
httpServletResponse.setContentType(image.getMimeType());
httpServletResponse.setContentLength(image.getLength());
httpServletResponse.getOutputStr

【在 h**d 的大作中提到】
: I have some images saved in db using BLOB.
: I need to display one image with other information using struts2 framework,
: now my action has the byte array of image.
: What's the easiest solution? What's the most elegant solution?
: What I can think about: save it as a temp file, and show it as a link in JSP.
: Thanks....

h**d
发帖数: 474
4
thanks, will give a try...
It seems that I have to write the image into the temp file first:(
I'm using struts2, which is actually webwork:)

【在 g*****g 的大作中提到】
: From browser point of view, your image is nothing more than
: a link, it has to be a known extension though otherwise some browser
: may not be able to render it as image.
: For Spring MVC, you can map all links to some folder,
: etc. /img/* to some controller, then you can write the
: image back, all you need to do is set appropriate image
: mime type. Sth. like
: httpServletResponse.setContentType(image.getMimeType());
: httpServletResponse.setContentLength(image.getLength());
: httpServletResponse.getOutputStr

m**c
发帖数: 192
5
goodbug说的这个方法不需要temp file吧
最好不要用temp file

【在 h**d 的大作中提到】
: thanks, will give a try...
: It seems that I have to write the image into the temp file first:(
: I'm using struts2, which is actually webwork:)

g*****g
发帖数: 34805
6
You don't, but on the other hand, if there's no security issue,
I'd seriously consider caching images in appserver. And only goto
DB if image cannot be found in cache.

【在 m**c 的大作中提到】
: goodbug说的这个方法不需要temp file吧
: 最好不要用temp file

h**d
发帖数: 474
7
I have to display other information other than this image...:(

【在 g*****g 的大作中提到】
: You don't, but on the other hand, if there's no security issue,
: I'd seriously consider caching images in appserver. And only goto
: DB if image cannot be found in cache.

1 (共1页)
进入Java版参与讨论
相关主题
[合集] Are JSPs Dead?JSP How to Invoke the Specific version of Xerces-J
Eclipse不能保存UTF-8文件?哪位大牛可以总结一下各种java框架的基本思想,优于其它框架的地方以及适用范围。
问问java认证请问JSP/SERVLET和MYSQL如何实现照片上载和调用
Oracle and SunJsp-Mysql for multitype resources
Question about Model 2J2EE和未来工作问题
唉进了一家烂公司interview求助
memcachedJSF有前途吗
FrameworkServlet?JSP + Spring MVC, Newark Delaware
相关话题的讨论汇总
话题: image话题: what话题: jsp话题: db话题: other