• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

uploading images and java

 
Mich Robinson
Ranch Hand
Posts: 260
1
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm thinking of starting a new project but I'm unsure whether I should use Java. It's a web application that allows people to build a quiz and I want the user to be able to add questions and images. Can you upload images in Java? Can the program then make use of that image? I figured that because the image isn't already in the jar (and in the right directory) then it can't be used by the program.

I wondered whether I could store any images in a central database and access them this way? is this difficult? Having this data separate in a database might make it easier to produce Android and iphone apps if I went that far (I probably won't). I could write the application in PHP but then I'd lose some functionality.

Any thoughts?

Mike
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64173
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, a web app powered by Java can upload and use images. It has nothing to do with jar files, of which many go into constructing a web app.

See the JSP and servlets FAQs fOr more info.
 
gurunath pai
Greenhorn
Posts: 13
Android Hibernate Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Its your call to decide which technology you want to use to develop a application, most of the things are supported in most of the technologies.
 
Mich Robinson
Ranch Hand
Posts: 260
1
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the input guys.

With the jars I have produced so far I can only access images that are in the current jar (ie already zipped up) or in the source directory of the jar. I presume you're saying a java app/applet can input an image and store it in it's home directory so that other users can use it? Can you point me at an example or a slightly longer explanation as to how to do this (or even some keywords I can google ). Cheers.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64173
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Web apps are fronted by HTML, usually produced by JSP templates. Images are not read from jar files, but are accessed by <img> elements in the HTML.

Are you sure it's a web app you want to write? It doesn't seem like you've got a good handle on how to approach that.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64173
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
With regards to file uploading, see the JspFaq and ServletsFaq for starters.
 
Pat Farrell
Rancher
Posts: 4660
5
Linux Mac OS X VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can do what you are asking, but as @bear asks, are you sure you have thought out the architecture for this?

Concerning storing images on your server, you have many choices. You can simply store the images as files that your webserver (apache, etc.) can read, or you can store the bytes of the image in a blob in your favorite database table in a DBMS (mysql, sqllite, oracle, etc.). Which you select is simply an engineering design question, there are pros and cons of each.
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic