Sunday, April 8, 2007

ImageServlet

Serve your images

Update: there's a newer article out for more effective file serving. You may find it useful: FileServlet supporting resume and caching and GZIP.

If you have stored images in a path outside of the web container or in a database, then the client cannot access the images directly by a relative URI. A good practice is to create a Servlet which loads the image from a path outside of the web container or from a database and then streams the image to the HttpServletResponse. You can pass the file name or the file ID as a part of the request URI. You can also consider to pass it as a request parameter, but that would cause problems with getting the filename right when the user want to save the image in certain web browsers by rightclicking and saving it (Internet Explorer and so on).

Back to top

ImageServlet serving from absolute path

Here is a basic example of a ImageServlet which serves a image from a path outside of the web container.

package com.example.controller;

import java.io.File;
import java.io.IOException;
import java.net.URLDecoder;
import java.nio.file.Files;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * The Image servlet for serving from absolute path.
 * @author BalusC
 * @link http://balusc.blogspot.com/2007/04/imageservlet.html
 */
@WebServlet("/image/*")
public class ImageServlet extends HttpServlet {

    // Properties ---------------------------------------------------------------------------------

    private String imagePath;

    // Init ---------------------------------------------------------------------------------------

    public void init() throws ServletException {

        // Define base path somehow. You can define it as init-param of the servlet.
        this.imagePath = "/var/webapp/images";

        // In a Windows environment with the Applicationserver running on the
        // c: volume, the above path is exactly the same as "c:\var\webapp\images".
        // In Linux/Mac/UNIX, it is just straightforward "/var/webapp/images".
    }

    // Actions ------------------------------------------------------------------------------------

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        // Get requested image by path info.
        String requestedImage = request.getPathInfo();

        // Check if file name is actually supplied to the request URI.
        if (requestedImage == null) {
            // Do your thing if the image is not supplied to the request URI.
            // Throw an exception, or send 404, or show default/warning image, or just ignore it.
            response.sendError(HttpServletResponse.SC_NOT_FOUND); // 404.
            return;
        }

        // Decode the file name (might contain spaces and on) and prepare file object.
        File image = new File(imagePath, URLDecoder.decode(requestedImage, "UTF-8"));

        // Check if file actually exists in filesystem.
        if (!image.exists()) {
            // Do your thing if the file appears to be non-existing.
            // Throw an exception, or send 404, or show default/warning image, or just ignore it.
            response.sendError(HttpServletResponse.SC_NOT_FOUND); // 404.
            return;
        }

        // Get content type by filename.
        String contentType = getServletContext().getMimeType(image.getName());

        // Check if file is actually an image (avoid download of other files by hackers!).
        // For all content types, see: http://www.w3schools.com/media/media_mimeref.asp
        if (contentType == null || !contentType.startsWith("image")) {
            // Do your thing if the file appears not being a real image.
            // Throw an exception, or send 404, or show default/warning image, or just ignore it.
            response.sendError(HttpServletResponse.SC_NOT_FOUND); // 404.
            return;
        }

        // Init servlet response.
        response.reset();
        response.setContentType(contentType);
        response.setHeader("Content-Length", String.valueOf(image.length()));

        // Write image content to response.
        Files.copy(image.toPath(), response.getOutputStream());
    }

}

Here are some basic use examples:

<!-- JSP -->
<img src="${pageContext.request.contextPath}/image/test.jpg" />
<img src="${pageContext.request.contextPath}/image/test.gif" />

<!-- Facelets -->
<img src="#{request.contextPath}/image/test.jpg" />
<img src="#{request.contextPath}/image/#{myBean.imageFileName}" />

<!-- JSF -->
<h:graphicImage value="image/test.jpg" />
<h:graphicImage value="image/test.gif" />
<h:graphicImage value="image/#{myBean.imageFileName}" />
Back to top

ImageServlet serving from database

In this simple example we assume "plain JDBC" (instead of EJB/JPA). First prepare a DTO (Data Transfer Object) for Image which can be used to hold information about the image. You can map this DTO to the database and use a DAO class to obtain it. You can get the image as byte[] from the database using ResultSet#getBytes().

The data layer and JDBC based DAO pattern is explained in this tutorial: DAO tutorial - the data layer.

package com.example.model;

public class Image {

    // Properties ---------------------------------------------------------------------------------

    private String id;
    private String name;
    private String contentType;
    private byte[] content;

    // Implement default getters and setters here.

}

Here is a basic example of a ImageServlet which serves a image from a database.

package com.example.controller;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.example.dao.DAOFactory;
import com.example.dao.ImageDAO;
import com.example.model.Image;

/**
 * The Image servlet for serving from database.
 * @author BalusC
 * @link http://balusc.blogspot.com/2007/04/imageservlet.html
 */
@WebServlet("/image/*")
public class ImageServlet extends HttpServlet {

    // Properties ---------------------------------------------------------------------------------

    private ImageDAO imageDAO;

    // Init ---------------------------------------------------------------------------------------

    public void init() throws ServletException {
        this.imageDAO = DAOFactory.getImageDAO();
    }

    // Actions ------------------------------------------------------------------------------------

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        // Get ID from request.
        String imageId = request.getParameter("id");

        // Check if ID is supplied to the request.
        if (imageId == null) {
            // Do your thing if the ID is not supplied to the request.
            // Throw an exception, or send 404, or show default/warning image, or just ignore it.
            response.sendError(HttpServletResponse.SC_NOT_FOUND); // 404.
            return;
        }

        // Lookup Image by ImageId in database.
        // Do your "SELECT * FROM Image WHERE ImageID" thing.
        Image image = imageDAO.find(imageId);

        // Check if image is actually retrieved from database.
        if (image == null) {
            // Do your thing if the image does not exist in database.
            // Throw an exception, or send 404, or show default/warning image, or just ignore it.
            response.sendError(HttpServletResponse.SC_NOT_FOUND); // 404.
            return;
        }

        // Init servlet response.
        response.reset();
        response.setContentType(image.getContentType());
        response.setContentLength(image.getContent().length);

        // Write image content to response.
        response.getOutputStream().write(image.getContent());
    }

}

Here are some basic use examples:

<!-- JSP -->
<img src="${pageContext.request.contextPath}/image?id=250d7f5086d02a46f9aeec9c51d43c63" />

<!-- Facelets -->
<img src="#{request.contextPath}/image?id=250d7f5086d02a46f9aeec9c51d43c63" />
<img src="#{request.contextPath}/image?id=#{myBean.imageId}" />

<!-- JSF -->
<h:graphicImage value="image?id=250d7f5086d02a46f9aeec9c51d43c63" />
<h:graphicImage value="image?id=#{myBean.imageId}" />
Back to top

Security considerations

In the last example of an ImageServlet serving from database, the ID is encrypted by MD5. It's your choice how you want to implement the use of ID, but keep in mind that plain numeric ID's like 1, 2, 3 and so on makes the hacker easy to guess for another images in the database, which they probably may not view at all. Then rather use a MD5 hash based on a combination of the numeric ID, the filename and the filesize for example. And last but not least, use PreparedStatement instead of a basic Statement to request the image by ID from database, otherwise you will risk an SQL injection when a hacker calls for example "image?id=';TRUNCATE TABLE Image--".

Back to top

Copyright - There is no copyright on the code. You can copy, change and distribute it freely. Just mentioning this site should be fair.

(C) April 2007, BalusC

106 comments:

Manu said...

You are the greatest. Thanx for your code and be sure I will go on singing your name. However I want to ask; do you know the code for displaying, say, 50 rows from a resultset in multiple pages, say 10 rows per page as in website search engines. Thanx.

Anonymous said...

Its really a nice code. Well structured and creatively generated. I think you must be such a great programmer. Especially at this part of code:
response.reset(); response.setContentLength(contentLength); response.setContentType(image.getContentType()); response.setHeader( "Content-disposition", "inline; filename=\"" + image.getFileName() + "\""); output = new BufferedOutputStream(response.getOutputStream());

BUT THE PROBLEM IS... Where is your import mydao.*;????!!!

BalusC said...

This is a fictive DAO. Just use your own DAO thing :)

KoBe said...

WOO, so cool. It is the greatest image retrieve from database example I saw.

Amit said...

Was very useful and really helped me in a situation when i was completely stuck...!

Amanda Lau a.k.a. Kristin Bean said...

Good example.
Give me briefly idean how to do.
but i still have a question, in my case, Im not getting an image from a folder and post in web browser.I got a code that need to be converted into an image and display on the web browser in jsp page.Thank you

BalusC said...

@Amanda Lau: check the Java 2D API.

José Mendes said...

I´m having a problem with JSF object Image in Firefox 3 and the Image Servlet. Page doesn´t load, and to get loaded i have to hit the "Refresh" button of the browser severall times. the same code works on firefox 2.x and worked in Firefox 3 but, since i´ve upgraded the glassfish server and Netbeans, whenever i use the Image Servlet the page doesn´t get loaded properly ... any ideas?

Unknown said...

Hi BalusC

First of all I want to thank you for making my life easier!
Now to my question, i am trying to display a image wich i am recovering from my mysql-db. I am converting this image from blob to byte[] in my bean. I want to display this image in my jsp page. Is there a way of doing this without using servlets?
i read somewere that h:graphicImage value="#{MyBean.imageArray}" should do the work, but i end up with
java.lang.ClassCastException
can i make this work or is the onley way to go with a servlet?
thank you for your time!

BalusC said...

You cannot put the raw byte array of the image as a value inside the 'src' attribute. The 'src' attribute must point to an URL where the image is located. Thus, yes, a Servlet is the only right way.

Unknown said...

Yes i figured that out =) i used your example and it works perfect!
thank you!

Rache said...

Thanks so much for this example . It worked out but my senior wants me to try without a servlet. Here's whay i did. I called a method in my backing bean on click of a button which does exactly what ur servlet does. Problem : My image comes in a seperate jspx whose url only differs some sessionid at the end.
Now how can i get my image to display in a page i specify that too within an img tag (or its like)Any clue??

Rache said...

is there any way I can pass the inputText value to the servlet parameter

graphicImage width="75"
value="/imageServlet?partyRefNo=#{DisplayBean.partyRef)"

BalusC said...

After you have submitted the form, yes. The EL in your example is only invalid. It shouldn't close with a parentheses ), but with a curly brace }.

rubyhunt42 said...

Thanks, very usefull article. I have used your idea to get images from static content server in my JSF application.

tam said...

I agree - this really is a very useful example. But how about caching? I have an application where the user will upload an image to a database. This image will then be displayed on the next page a for all future pages they see on that visit. Will it be necessary to go back to the database for each page?
Thanks,
Tom

tam said...

Worked it out for myself - just added the line:

response.setHeader("Expires", "Thu, 15 Apr 2010 20:00:00 GMT");

to the servlet (where the date is any date in the future obviously) and caching occurred.

Thanks again.
Tom

chetan said...

I got the code's working.It is taking image from local file system and encoding it into the URL.
But how should I call this servlet .If my file is located at c:\zero.jpg

Just give simple example.

Thanks :)

BalusC said...

That's already explained in the article. Do not only copypaste the ImageServlet class, but also read the article's text and the remnant code snippets for web.xml and JSP file.

Unknown said...

Good code , it worked for me :)

Anonymous said...

Hi there

for the Imageservlet what is the parameter if the image doesn't exist. then go to a default one..

BalusC said...

Just let it point to some default image. E.g.

if (!image.exists()) {
    image = new File(imagePath, "default.gif");
}

Anonymous said...

Thanks I am doing the non database ImageServlet...

Can you tell me where to put that code?

BalusC said...

Please read the code example and the code comments.

Anonymous said...

I am pretty new to jsp..

I did read the code and comments and that's why I am asking you the question... there is 2 lines with the same line.

// Throw an exception, or send 404, or show default/warning image, or just ignore it.

I wanted to know where to put the code since it is displayed twice.

sorry if I am a pain in the ass...

BalusC said...

You don't need to add it as a new if statement, but you need to replace the existing one. It is not a matter of JSP, but just of the understanding the flow in Java code and what exactly each line is doing :)

Itzik Yatom said...
This comment has been removed by the author.
Itzik Yatom said...

Thanks, very helpful.

FigMan said...

In your example for "ImageServlet serving from absolute path", is it possible to pass the path/filename as a parameter to the ImageServlet?
It's working when hardcoded as in your example, but I need to do this dynamically. I'm having trouble doing so.. thanks!

BalusC said...

Just pass it the same way as filename.

FigMan said...

To clarify, this is in a JSP, and I would like to replace the line
img src="image/test.gif" /> with something like img src="image/pathAndNameVar" /> .
I've tried something like:
img src="image/"+opener.document.forms[0].fName.value /> , but instead of the path and file name being passed to the servlet, the text "opener.document.forms[0].fName.value" was passed

BalusC said...

use src="image/some/extra/path/filename.jpg". The "hardcoded" path is just the root path where all images can be found.

FigMan said...

I do understand how your example is working, I know that images is hardcoded in the servlet; I would like that root folder removed from the servlet, and pass to it random paths and file names, the origin of which is input type=file name="fName"> in a parent window.

BalusC said...

This is a security hole. You don't want that the hacker can call "http://example.com/image/c:/passwords.txt".

FigMan said...

Is there no way to do this? The html control input=file returns something like "C:\books\hemingway\OldManAndSea.jpg". I'm simply trying to pass this value in a variable to the Servlet. Getting the impression that this is a syntax issue, not a security issue. Not even sure that matters but I wouldn't mind manipulating the string "C:\books\hemingway\OldManAndSea.jpg" to make it "books\hemingway\OldManAndSea.jpg". Sorry, not trying to be difficult..

FigMan said...

To simplify this question, could you show me what your code [ i.e. img src="image/test.jpg" ]
would look like if you wanted to pass 'test.jpg' to the servlet in a variable and not hard code it? Perhaps I can work backwards from there.

Thanks..

BalusC said...

Just use EL the usual way. E.g. img src="images/${filename}"

FigMan said...

Thanks, but now I get to sound ignorant.. I have no idea what that means. With the dollar sign in there, it looks more like php than JSP syntax to me.. still clueless here..

BalusC said...

Expression Language

It's the way to access backend data in JSP. It has replaced the old fashioned scriptlets (the ugly and errorprone <% %> things) over 10 years ago.

FigMan said...

Great, thanks for your help! I appreciate it.. will post back with how I made out.

FigMan said...

Well, that was a serious brain fart on my part.. using a JSP expression tag was all I needed to do from the get go.. don't know why I was trying other approaches to fill that parameter.. thanks again!

sajja said...

This is a good example. I need to re-size the image before outputting. Because my image are larger file sizes (3MB+). First I need to thumbnail images to a smaller size. When the user selects a particular image it can be shown its original size. Can anybody help me.

Unknown said...

I want to uplaod a image in my jsp.
I want as soon as the image is uploaded , the image should appear in at the side as a preview.
I am able to load the image but it not visible at the side as a preview.

BalusC said...

Either you didn't close file after write, or the file is at wrong location, or the URL is wrong.

Unknown said...

Great code. I do something similiar but not as complete. I use a similiar technique to display Word, Excel, PP docs. When I try to display Word 2007 docs, however, nothing gets displayed and Excel 2007 docs display but only after indicating a corrupted file. I have included the new 2007 mime types. Any ideas ?

BalusC said...

Use the FileServlet instead. http://balusc.blogspot.com/2007/07/fileservlet.html

Unknown said...

can you post imageDao file ? i cant complie without that ~ thanks

BalusC said...

You need to write it yourself. It's just a DAO class. Do your DB interaction thing using JDBC, Hibernate, JPA or whatever.

Diego M said...

Hello,

I tried adding this to my portlet's package and placed the proper lines in my web.xml file.

When I run it from eclipse directly on tomcat, the imageservlet works just fine. But when I export as WAR and run it inside liferay, the imageServlet isnt even getting called. I know this because I've placed some output code inside it that isnt showing up in the logs when executing inside liferay.

My Stack Overflow question:
http://stackoverflow.com/questions/3225387/liferay-portlet-imageservlet-baluscs-code-problem

Any help you can provide would be great!

Diego M said...

Hello,

I tried adding this to my portlet's package and placed the proper lines in my web.xml file.

When I run it from eclipse directly on tomcat, the imageservlet works just fine. But when I export as WAR and run it inside liferay, the imageServlet isnt even getting called. I know this because I've placed some output code inside it that isnt showing up in the logs when executing inside liferay.

My Stack Overflow question:
http://stackoverflow.com/questions/3225387/liferay-portlet-imageservlet-baluscs-code-problem

Any help you can provide would be great!

Sanjeev Kulkarni said...

Hi, a very nice article, thanks for sharing. I have few doubts please let me know how to solve them: I have to create a employee profile page where he enters his name, birth date, address etc. along with his photo. Just like in all social n/w applications. My question is how to provide uploading of photo in this scenario? I tried using two forms, one for photo and another for rest of the details. Once a user uploads a photo and clicks on update button his photo will be stored in the database and will be displayed using a servlet in another page. How can I make this image to be displayed in the same jsp page from where it's being uploaded? Any help on this is appreciated. Thanks...

Yinch Worm said...

Thanks BalusC!
I have a question: when your specify \<\img src=image/test.gif> how is this turned into a form action? Don't you need to use \<\form action=image/test.gif> ? when I do the later, the page came back turned into the image I specified, not my original html, is there a way to do that? thanks in advance.

Yinch

Yinch Worm said...
This comment has been removed by the author.
Yinch Worm said...
This comment has been removed by the author.
Yinch Worm said...

I got it figured out...

"src=image/....", when there is no "/" in front of image, it invokes the URL patterns defined in web.xml

Works great, thanks man!

Yinch Worm said...

"/" turned out to be needed after all. Ehhhuh..but not need for form and submit mechanism.

PLU said...

Thank you so much for sharing this code, you have saved me so many potential headaches!!!!

Shubhangam said...

Could you please tell me how to do event handling on a JPEG file or an image?

Udara said...

Hi BalusC,

Thank you very much for this tutorial. I looked lot of places to find this kind of tutorial.

Arnaud said...

Hi thank for your code but i am having some problems: 1- How to invoque the "ImageServlet" servlet in my backing bean ?. 2- the "imageFileName" variable in the jsf page refers to what?

Arnaud said...

It's been days that I am on it and it stil not working.

Arnaud said...

Hi? i am sorry to have to insist, but can anyone here explain to me how to get "imageFileName" in the backing bean ? It is realy very URGENT. Thanks.

BalusC said...

It should just return the image file name as string, like "foo.gif".

Arnaud said...

Thanks man. you cannot image how helpfull was the message you just sent.

THANKS

JavaB said...

Hi,

I used your example and was able to retrieve images from file server. Now I want to retrieve images from a web " https://*/*/xyz.jpg."
I specified the image path as "https://*/*" but when i try to display the images using jsp , it just didn't display. can you point out my problem ?

Thanks

michael said...

Thank you very much.

But what if I want to open an image that is on another volume, e.g. the Tomcat is running under C: and the file I'd like to retrieve lies on volume Y:?

BalusC said...

Just use `this.imagePath = "Y:/images";`

Mike said...

Just wanted to echo all of the thanks for the code. Yet again, a simple (non-bloated) solution for my current need. I can't count the amount of code running in my app that's come from your site or your posts on stackoverflow. Much appreciated!

Mike

sunnybell said...

Thank you so much for the code, BalucS! It is very helpful. Great job!

Arjun Adhikari said...

hi BalusC
your code was quite helpful but i m having a problem while displaying blob data from the database as my data consists of different types of format and when i try to open or save them in my webpage its not happening
could you tell me where i m going wrong...

Arjun Adhikari said...

finally i cracked it...
took me a good part of four days to do so but success has never been so sweet..
able to download any type of blob file from my database now with the option to open and save it...

Special thanks goes to BalusC
keep up the good work

Juan Javaloyes said...
This comment has been removed by the author.
David Karam said...

thanks a lot! still works after 5 years :-)

Unknown said...

Will this work for me? I'm using Richfaces/JPA and was curious how to make this work in this context. Please see my issue here: https://community.jboss.org/message/745056#745056

jayku said...

This is great code, works really well. I want to also upload the file and same it on the server, how can that be done?

Unknown said...

Hi, I saw your post on rendering blob type image through simple servlet.
But in my case i am using Spring MVC controller and simple image servlet as you used.
Before ImageServlet i made one method in Spring Controller class and mapped with url(/image),this method didn't call (i am using img src="/image?id=${file.id}"/ in jsp) as well as ImageServet which i made when my controller class method was not calling.
Could you please resolve this issue.
For ImageServlet in web.xml i did url-mapping /image*.

Unknown said...

As you have mentioned some comment on url (http://stackoverflow.com/questions/6347752/how-to-show-a-jsp-page-using-servlet-which-has-image-in-its-response) need to add ${pageContext.request.contextPath} in image tag of jsp, this is also not working for me (neither servlet nor controller method called). I am saying this because i want to display bolb image as well some text on jsp file.When i am using Output stream then only image is rendering on jsp, text didn't render. this is the main issue with me. You can refer this link as well
(http://stackoverflow.com/questions/13101177/blob-image-render-in-spring-mvc-3-0/13103944#comment17826980_13103944)

Abc said...

really appreciate your work man. From last few days i have been working on this to display the image uploaded on the jsp page itself. your code help me fixing the issue.

jayku said...

Its really nice and works perfectly. Can you also post the example on how to upload the image with doPost? I want to upload the image from Android and save it on the server. Also want thumbnail and largimages if that is also possible.

k.praveen said...

Hi.. BalusC sir... looking at your code seems your are a very good programmer.. i am new to jsp servlet programming.. I would like to ask you for code related to "Image Upload through (browser)jsp and display that image on Browser(Jsp) and can we code this without using database?? i am using Eclipse IDE. and i want this service to deploy in some cloud service providing site.. can any one help me..

bouiks_blog said...

Hi balusC I tried this code and it works fine with Chrome and IE.But in firefox and opera, there is a problem.
The url is not requested under firefox;but under chrome this is a trace
INFO: requestedImage = /C:/Images/easy/tonio.jpeg

Muhammad Jawad said...

thanks....i want to add java web services in my project to request and retrieve images from display....kindly tell where i will add code....and which code i will add....kindly help me i am a beginner...thanks in advance.

Zach Matu said...

hi baluc..the code doesnt work on windows 7.any turnaround?

Unknown said...

I have an image list to show in datatable. How can I do this with HttpServlet

alibat said...

Hi.
I'am from Dakar in Senegal.
You are really the best. You saved my life. Thanks Thanks Thanks.
Nobel price for you.

Unknown said...

hey BalusC,
Thanks , for the code,
but m still facing a problem in viewing img.. the flow dosnt move to Imageservlet when image/test.jpg comes

Unknown said...

Sir, I am uploading an Image and that will be stored inside application and after that I am displaying that image but it doesn't display because untill I manually refresh running application it is not going to display.
So is there any code or technique that implemented then my application(running) will automatically refresh to show updated data/image.

Hope You Understand and help me ASAP.
Thank You.

Unknown said...

Thank you very much :)
please keep giving knowleagde :)

mem said...

I'm trying this and getting null from the request.getPathInfo() in the doGet(). Any idea on why? BTW, the servlet wasn't executing, I had to add a to the jsp to make it get there. Could it be related to that?

mem said...

in my prior post, some of the content was lost. The last part should have said, "I had to add 'jsp include' to the jsp to make it get there. Could it be related to that?"

Shrikant said...

Hello...why did not you posted the complete example with jsp/servlet/pojo/model ...??

find confusing little bit...

better give complete example.

Guru said...

Really useful..

Unknown said...

Let me ask a humble question is posible convert the servlet that you wrote into controller or action (Spring, Struts 2) Thanks

Unknown said...

Let me ask a hunble question is paossible to convert the servlet that you wrote in Controller or Action (Spring , Struts) Thanks

Unknown said...

hi, great work, but i like to put my requirement.
i am getting image absolute path from a json string in jquery ajax, and then i am passing that path as a request parameter to my image servlet, but my problem is that in a single shot iam getting 10 or more images(as i need to put them in a slideshow)and i am passing all to servlet in a loop, now their will be a synchronization problem occured.
How to handle it?
Iam developing an ecommerce site.
So any other good way to store images and to display them.
iam using jboss 7.1.1 ap server.

from our admin module we are directly storing images in root dir(linux)in Images folder.

And i also need to display video with the click of button.
how to do it.
max video size is - 5mb
please provide your assistance asap.

Unknown said...

Gracias!!!
Me tomo un tiempo el hacerlo funcionar, todo bien.

Unknown said...

I uses this final var:
public static final String PATH_IMAGEM_NOTICIA = File.separator + "portal-upload" + File.separator + "img-noticia" + File.separator;

Works on Linux and Windows,

Tks BalusC, your codes are awesome!

Unknown said...

Thank you very much Balus C. You are a genius. It works perfectly

Unknown said...

Works perfectly.
thanks you very much BaluC, your are and expert intercontinental.

mgfurtado said...

Really Thank you by this code!!!

Ravikant said...

nice tutorial. really it save my day.

Unknown said...

Hi,

i want to ask you.. if i'm using wildfly JBoss 10 how can I configure it?

Thanks.

Mr. Lewis said...

Humble bow to you sir!

Unknown said...

Good day chief i appreciate your effort for make dis open source but i just wanted too ask pls how can i download to dao factory to my computer

baudouin said...

perfet!

Unknown said...

BalusC! You are the man!