I am working on a JSP project where the user needs to upload an image.
I need this image to be stored into the database so that it can be retrieved from the database later on. I need to show that image in the webpage itself as soon as the image has been loaded. I have tried several option like uploadbean, spring-3-mvc-fileupload-example.html, etc but nothing is working out for me.
Can you please give me a simple but effective way to do this? I am working with MySQL database.
Apurv I suggest you look at this library
http://commons.apache.org/fileupload/
The user guide is at http://commons.apache.org/fileupload/using.html
Try this one: http://commons.apache.org/fileupload/. It is simple and works fine. Although Spring also has wrapper for this component and I used it either directly or via Spring and both worked fine for me.
Related
I am unable to upload a product image in broadleaf commerce via the broadleaf admin site. When I try to upload image from a local file, I get the following error
HTTP ERROR 500
Problem accessing /admin/asset/uploadAsset. Reason:
File operation attempted on file that is not in provided work area. D:\DOCUME~1\Gutha\LOCALS~1\Temp\5e\a2\gal_w01.jpg. Work area = D:\DOCUME~1\Gutha\LOCALS~1\Temp\/5e/a2/
I tried creating that folder, and placing the image in that area, but it is of no use becaues each time a new folder is being shown here. Could any one tell me where should I place the images to be uploaded?
Thanks in advance.
Sounds like a bug. I've opened a ticket that you can track here ...
https://github.com/BroadleafCommerce/BroadleafCommerce/issues/773
If you can, let us know what version you are running into the issue in the above ticket.
FYI, I work for Broadleaf Commerce.
Actually I'm doing Sample Application,
We are Observe many of social networks, in that Profile images are their, When ever mouse over it is asking Upload new Image.
So i want to Develop Same Application .
When ever we write <input type="file"/> then it is asking file and now add value(image) into .. So how to add this value.
Their is only one click browse image and upload image...
And now how to handle this one into Spring side..
Please Suggest me..
I thing you need to use ajax to do this. Click here to see a demo in PHP. They show how to done that in PHP. Instead of PHP you can use Spring with JSON to complete that.
I wrote sql but it takes more time when execute it in jsp. And I want to make faster it. Will grid view make the page faster?
I'm junior in Java. I researched in google but didn't find clear sample about gridview. Can u help me?
I understand you have a web based application backed by the DB.
Note that gridview is not something offered by Java, instead you can create tables by using your web frameworks and render data there.
You say, it takes a lot of time to execute an SQL when running withing JSP. Where the time goes?
Running the SQL itself? Maybe creating a JSP or transmitting it to the client browser in an Html form, or even maybe the rendering of your table in browser?
You should detect the bottleneck in order to understand what you're going to fix
Consider to use profiler and see (at least on server vm) where the time goes.
I think JVisualVM will suit your needs here.
Hope this helps
I would have done this task using following steps
Create one servlet.
Connect to the database and fetch the data which we have to display.
Create a list and keep the data in list it.
Set the list in request and forward the control to JSP.
On JSP, use DisplayTag to show the data in grid form.
Hope this helps you.
In my project users upload image files which are saved outside the context root in the drives. I need to show these images in a jsp. I use struts2. Any help will be appreciated.
Take a look to this tutorial. I think that is exactly what you are looking for.
Edit:
The idea is to tell the action what image you want. That is done adding a parameter in the request. In the example, for instance, it is use the parameter imageId but you can change this strategy and use a different thing, like the image name. Then you should call the action in this way (according to the tutorial):
http://localhost:8080/myAppContext/ImageAction?imageId=darksouls.jpg
Also, take in mind the #Dave Newton's comment as a very good alternative. See this other example for that.
I am working on a app where I would like to download images from a website and then save those images into a sqlite database. I tried already to find some good tutorials and the only thing that came close to what I would like to do, is a article by Tim Bray.
http://android-developers.blogspot.de/2010/07/multithreading-for-performance.html
The code is really nice however it does not account for saving each single image. Bitmap unfortunatley (as far as I understand) does not distinguish between each image.
I would like to ask if anybody could give me some pointers or even better has source code for such a problem.
If you want to store images into a database you can store them as a BLOB-value.
Take a look here for that part: http://www.tutorialforandroid.com/2009/10/how-to-insert-image-data-to-sqlite.html