kavin clain wrote:I want to show images which are saved in database.
No problem. Just write a servlet that streams the data from the DB and sets the appropriate response headers. Then you can reference the servlet from anywhere that you can reference an image (<img> tag, CSS, etc)
I am sending request using ajax.
Problem. Why are using Ajax to fetch an image? What would you do with it?
How to respond using Action class.
See answer above about servlets.
how to dynamically set the image as div background or img tag?
That's just a matter of CSS. You don't need to fetch the image data -- just set the styles to reference the image URL.
Where ImageStreamer is your servlet/action/whatever and 23 is the ID of the image to fetch from the database. Then stream the bytes of the file (not a java.awt.Image object) back to the client.