[Last Call] Learn how to a build a cloud-first strategyRegister Now


How load data into <hml:img>?

Posted on 2006-06-06
Medium Priority
Last Modified: 2008-02-01
I have a Class with Search feature.
---- User user=new User()
BillAction Class
Tour td=new Tour();
Question by:khoa235
LVL 10

Expert Comment

ID: 16846030
Guess the question is grossly incomplete.


Author Comment

ID: 16848328
How to load data under image file (Database) on <html:img> or <html:image>?
I am testing but only display image file. I am using <bean:write name  property> tag.
Everyone can help me to solve that propblem! Thanks.

Accepted Solution

evnafets earned 80 total points
ID: 16848871
Doing something like this is a two part action
1 - generate <img> tag in the html.
2 - generate the image and send it back via servlet output stream.

It is actually two requests - one for the jsp page, another for the image.
When the jsp page is loaded, the browser sends a new request to get the image.

Since you are using struts, I will detail the struts method.  Basically you need two actions.  One for the page, the other for the image.
On the page you specify your <html:img> tag something like this
<html:img action="/getImageAction"/>

You then define getImageAction in your struts-config.xml, and have its action get the output stream, and write the image out to it (setting the appropriate content types of course)

See here for documentation on the options with the html:img tag: http://struts.apache.org/struts-action/struts-taglib/tlddoc/html/tld-summary.html

Hope this helps,
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!


Author Comment

ID: 16851395
I don't understand. Because I have a Class include search method. In this method() I set image field into tour object. When I submit, file imge would loaded on <html:img>.
LVL 35

Expert Comment

ID: 16851434
You cannot "embed" images in this way.  That's not how HTML (which is what you are generating) works

You will have to do it the way evnafets says.  Basically, write an image tag that points to a servlet, JSP, or Action class

Then write this JSP, servlet or action class so it encodes the Image as a JPG or PNG in the OutputStream

eg: http://weblogs.java.net/blog/jfalkner/archive/2005/05/blarg_15_how_ca.html


Author Comment

ID: 16857894
image file into database. common JSP programming, I can do that but Struts very difficult. everyone have solution to do that ? Only load image file into <html:img>tag.
LVL 35

Expert Comment

ID: 16859283
I don't understand your last comment :-(

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Currently, there is an issue with being able to copy values from an external application to a dropdown list in Project Web Access (PWA).  The standard copy and paste methods don't seem to work properly. Here is a way to accomplish this task to s…
LinkedIn blogging is great for networking, building up an audience, and expanding your influence as well. However, if you want to achieve these results, you need to work really hard to make your post worth liking and sharing. Here are 4 tips that ca…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Suggested Courses
Course of the Month18 days, 8 hours left to enroll

826 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question