Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > image from jar to web page?

Reply
Thread Tools

image from jar to web page?

 
 
Andrew Thompson
Guest
Posts: n/a
 
      11-23-2003
How can I get an image from a jar file into
a web page?

I am using JSP to haul the goodies out of my
PhySci software suite and onto the net as web
pages, thus far I have turned PToE (Periodic Table)
into a crude 113 page website at..
http://1point1c.physci.org/chemistry/

Next up is Pocket Planet, containing basic information
on the planets.

The problem is, I cannot figure how to grab images
out of a jar archive and put them into a web page.

[ Short of presenting them in an applet, which I want
to avoid (I want these sites to be usable by people
with 'no java') ]

Can somebody point me to a tutorial or give me
some good search terms that will put me on the
right path?

TIA

--
Andrew Thompson
* http://www.PhySci.org/ PhySci software suite
* http://www.1point1C.org/ 1.1C - Superluminal!
* http://www.AThompson.info/andrew/ personal site


 
Reply With Quote
 
 
 
 
J.P.Jarolim
Guest
Posts: n/a
 
      11-23-2003
Hi.

Do you want to keep the images in the jar?
You can use winzip (just copy and rename the jar to zip) and put the images
somewhere the webserver can reach them.
But there surely is a possibility to use them out of the jar anyway.

If you want to use them out-of-the-jar i'll take a look.

greets,

J.P.Jarolim


Andrew Thompson wrote:
> How can I get an image from a jar file into
> a web page?
>
> I am using JSP to haul the goodies out of my
> PhySci software suite and onto the net as web
> pages, thus far I have turned PToE (Periodic Table)
> into a crude 113 page website at..
> http://1point1c.physci.org/chemistry/
>
> Next up is Pocket Planet, containing basic information
> on the planets.
>
> The problem is, I cannot figure how to grab images
> out of a jar archive and put them into a web page.
>
> [ Short of presenting them in an applet, which I want
> to avoid (I want these sites to be usable by people
> with 'no java') ]
>
> Can somebody point me to a tutorial or give me
> some good search terms that will put me on the
> right path?
>
> TIA



 
Reply With Quote
 
 
 
 
Andrew Thompson
Guest
Posts: n/a
 
      11-23-2003
"J.P.Jarolim" <> wrote in message
news:3fc099df$0$32146$ y.telekom.at...
...
> Do you want to keep the images in the jar?


Yep, sure do!

I need be confident that the web pages will
update if the jar changes. ..Not that that would
be a major problem for the planets, but if I were
to add another package containing the moons,
the 'moons.jar' may change on a regular basis.

[ I could, conceivably unpack the jar before
upload, but that seems like a terribly
inefficient 'solution'.. ]

Alternatively, I could have the files extracted
from the .jar and reproduced on the server
as uncompressed images the first time they
are called, but I do not want to create a
proliferation of files on the server.

Thanks for your suggestion though.

--
Andrew Thompson
* http://www.PhySci.org/ PhySci software suite
* http://www.1point1C.org/ 1.1C - Superluminal!
* http://www.AThompson.info/andrew/ personal site


 
Reply With Quote
 
J.P.Jarolim
Guest
Posts: n/a
 
      11-23-2003
Hi.

So you should have a look at
Object.getClass().getClassLoader().getResource()
Thats the way to get a file located in the same jar as the executed
program - so there should be a way to get files out of another jar around
imho.

Additionally you can create a servlet which reads the raw file content and
serves it to the browser.
You should change the mime-return-type of the servlet to image/jpeg or
whatever you want to serve.

greets,

J.P.Jarolim


Andrew Thompson wrote:
> "J.P.Jarolim" <> wrote in message
> news:3fc099df$0$32146$ y.telekom.at...
> ..
>> Do you want to keep the images in the jar?

>
> Yep, sure do!
>
> I need be confident that the web pages will
> update if the jar changes. ..Not that that would
> be a major problem for the planets, but if I were
> to add another package containing the moons,
> the 'moons.jar' may change on a regular basis.
>
> [ I could, conceivably unpack the jar before
> upload, but that seems like a terribly
> inefficient 'solution'.. ]
>
> Alternatively, I could have the files extracted
> from the .jar and reproduced on the server
> as uncompressed images the first time they
> are called, but I do not want to create a
> proliferation of files on the server.
>
> Thanks for your suggestion though.



 
Reply With Quote
 
Andrew Thompson
Guest
Posts: n/a
 
      11-23-2003
"J.P.Jarolim" <> wrote in message
news:3fc0a6d7$0$28626$ y.telekom.at...
.....
> So you should have a look at
> Object.getClass().getClassLoader().getResource()
> Thats the way to get a file located in the same jar as the executed
> program - so there should be a way to get files out of another jar around
> imho.
>
> Additionally you can create a servlet which reads the raw file content and
> serves it to the browser.
> You should change the mime-return-type of the servlet to image/jpeg or
> whatever you want to serve.


Sorry! It's one of those, 'what to put in,
what to leave out' things - where apparently
I misjudged on two counts..

a) Forgot to mention that I also want to
create new images (eg graphs of data)
and present them in pages as well.
(So occasionally the images will not exist till
moments before they are delivered to the
web surfer)

b) _Not_ using the image/jpeg thing.
First, because I wish to put the images
into pages containing other, textual data,
and AFAIU that content type is only
suitable for a single image.
Second, because I thought I'd read
somewhere that it had been deprecated(??)
(not sure whether by Sun or W3C)

Perhaps I should also point out that actually
getting the images is not a problem, I have already
created applets that present zip/jar files as
directory structures that can display html (complete
with images) in a (otherwise horrendously poor)
JEditorPane. e.g.
http://www.physci.org/applet/Ziplet.htm

--
Andrew Thompson
* http://www.PhySci.org/ PhySci software suite
* http://www.1point1C.org/ 1.1C - Superluminal!
* http://www.AThompson.info/andrew/ personal site


 
Reply With Quote
 
J.P.Jarolim
Guest
Posts: n/a
 
      11-23-2003
Hi.

> a) Forgot to mention that I also want to
> create new images (eg graphs of data)
> and present them in pages as well.
> (So occasionally the images will not exist till
> moments before they are delivered to the
> web surfer)


So - whats exactly your problem?
What's the question about images in a jar - apparently you have to create
and deliver your images on the fly?
Please explain your problem again in full detail.

> b) _Not_ using the image/jpeg thing.
> First, because I wish to put the images
> into pages containing other, textual data,
> and AFAIU that content type is only
> suitable for a single image.
> Second, because I thought I'd read
> somewhere that it had been deprecated(??)
> (not sure whether by Sun or W3C)


Same thing - Please explain again, what you want to do.
Btw. you have to treat every image you create as a single image.
Jpeg isn't deprecated either and gif is a legal problem (in europe at
least).

> Perhaps I should also point out that actually
> getting the images is not a problem, I have already
> created applets that present zip/jar files as
> directory structures that can display html (complete
> with images) in a (otherwise horrendously poor)
> JEditorPane. e.g.


So - what is your problem here??
Please learn to state your problem so someone can actually answer it.
Btw. your applet doesn't work with ie6 and the standard ie-java-plugin.

greets,

J.P.Jarolim


 
Reply With Quote
 
Tim Tyler
Guest
Posts: n/a
 
      11-23-2003
J.P.Jarolim <> wrote or quoted:

>> Perhaps I should also point out that actually
>> getting the images is not a problem, I have already
>> created applets that present zip/jar files as
>> directory structures that can display html (complete
>> with images) in a (otherwise horrendously poor)
>> JEditorPane. e.g.

>
> So - what is your problem here??
> Please learn to state your problem so someone can actually answer it.


I think he explained why a Java solution was unsatisfactory:

``Short of presenting them in an applet, which I want to avoid
(I want these sites to be usable by people with 'no java')''

> Btw. your applet doesn't work with ie6 and the standard ie-java-plugin.


The MS JVM? Hardly suprising - since it uses a JEditorPane.
--
__________
|im |yler http://timtyler.org/ Remove lock to reply.
 
Reply With Quote
 
Tim Tyler
Guest
Posts: n/a
 
      11-23-2003
Andrew Thompson <> wrote or quoted:

> How can I get an image from a jar file into
> a web page?


If your clients use Mozilla/Firebird, you can just go:

jar:http://mandala.co.uk/imagesinjars/test.jar!/test.gif

....and it accesses the file.

For a more portable solution you will probably have to extract
them into temporary files on the server.
--
__________
|im |yler http://timtyler.org/ Remove lock to reply.
 
Reply With Quote
 
Andrew Thompson
Guest
Posts: n/a
 
      11-23-2003
"Tim Tyler" <> wrote in message news:...
> Andrew Thompson <> wrote or quoted:
>
> > How can I get an image from a jar file into
> > a web page?

>
> If your clients use Mozilla/Firebird, you can just go:
>
> jar:http://mandala.co.uk/imagesinjars/test.jar!/test.gif


Way cool! Now if they could only make IE that way..

In fact, just for the hell of it, I tried it in IE.
'Invalid Syntax Error' ...hmmm.
As opposed to a ..'Valid Syntax Error'?

> For a more portable solution you will probably have to extract
> them into temporary files on the server.


Sounds like the best solution.
I am not sure how to do that, but I'll look into it.

[ Last time I dealt with temporary files was back in
the Amiga days - I am not even clear whether 'temporary'
files assume the programmer will delete*, or whether it
is part of the undelying OS.
* For that matter - I don't even know whether 'delete'
is the correct term. ]

Thanks Tim.

Thanks as well to J.P., for his/her time and effort.

--
Andrew Thompson
* http://www.PhySci.org/ PhySci software suite
* http://www.1point1C.org/ 1.1C - Superluminal!
* http://www.AThompson.info/andrew/ personal site


 
Reply With Quote
 
Andrew Thompson
Guest
Posts: n/a
 
      11-24-2003
"Andrew Thompson" <> wrote in message
newsE8wb.24082$...
> "Tim Tyler" <> wrote in message

news:...
> > Andrew Thompson <> wrote or quoted:
> >
> > > How can I get an image from a jar file into
> > > a web page?

....
> > For a more portable solution you will probably have to extract
> > them into temporary files on the server.

....
> I am not sure how to do that, but I'll look into it.


Now that I go back and RTFM I spot
File.createTempFile().

[ Like ...duh! ]

Solves the entire problem as far as I can see.
I'll write some code out over the next week
and give it a go..

--
Andrew Thompson
* http://www.PhySci.org/ PhySci software suite
* http://www.1point1C.org/ 1.1C - Superluminal!
* http://www.AThompson.info/andrew/ personal site


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
java -cp a.jar -jar b.jar => Works on Windows, not on Debian cyberco Java 4 02-14-2006 06:27 AM
jaas.jar, jta.jar jdbc-stdext.jar missing from jdk1.5 RPM muttley Java 0 10-20-2005 02:40 PM
Differences of xercesImpl.jar, xercesImpl-J.jar, dom3-xercesImpl.jar ? Arnold Peters Java 0 01-05-2005 10:59 PM
Differences of xercesImpl.jar, xercesImpl-J.jar, dom3-xercesImpl.jar ? Arnold Peters XML 0 01-05-2005 10:59 PM
Jar file cannot find main class - gfSetup.jar (0/1) James Alan Farrell Java 6 01-09-2004 12:40 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57