How load data into <hml:img>?

Posted on 2006-06-06
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

    Guess the question is grossly incomplete.


    Author Comment

    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.
    LVL 4

    Accepted Solution

    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:

    Hope this helps,

    Author Comment

    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

    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



    Author Comment

    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

    I don't understand your last comment :-(

    Featured Post

    What Should I Do With This Threat Intelligence?

    Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

    Join & Write a Comment

    Suggested Solutions

    Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
    Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
    Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
    how to add IIS SMTP to handle application/Scanner relays into office 365.

    746 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

    Need Help in Real-Time?

    Connect with top rated Experts

    13 Experts available now in Live!

    Get 1:1 Help Now