• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Writing to file and dynamic image pages.

 
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I have used Tomcat. Now I use Tomcat4.0 Winnt version. whenever I create a new file for writting itis created in the system32 directory of winnt. I have not tried giving the full path as I wonder if it works.
In fact it failed when I tested with Jrun3.0 where the file is created in the default dir.
What I want to do is using some Image Api s like JAI,Graphics2D I want to embed an image that is dynamically created into the page, and in the process save it.Here I would like to generate reports in the form of barcharts and pie charts.
Now if I create a jpeg image and save it,it goes to the system32 directory.We cannot thus give the HREF to the image in the response.
I was able to send an image by seting the content type. But I want also HTML matter to go with it.
Prashanth
 
Ranch Hand
Posts: 321
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Prasanth,
Just awild guess, while sending image to the page, you must writing the bytes to the stream right? In the process why don't you write the html output also to the stream?
 
Prashanth menon
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
True,
Images are sent as stream. I use JpegEncoder. But how does the browser recognize the mime type. Naturally I specify the content-type. But that is the header part of what I send. Once an Image/jpeg content is written to output how can an html content be sent.
The earlier problem has a solution something like this, may be
in a jsp page or servlet
out.println("<Img src=\"http://myserver/servlet/ ImageProcessServlet\">");
in this case the contentype set is text/html
At the same time in the ImageProcessServlet the contentype returned is Image/jpeg. Hence it works.
What I wanted to know was if it was possible to write to the html documents folder or where http protocol could access I could directly place the tag href="filename". May be it has been eliminated because of security reasons.
But I felt the problem more pushing when I could not save the file uploaded as multipart to the http folder. Take this case.
A client uploads an image at a portal. If the image is in the default folder then I must write another servlet like the one above to read and send it to the servlet requested. This image should be shown to the Client whenever he logs in or anyone checks his profile.
regards
Prashanth
reply
    Bookmark Topic Watch Topic
  • New Topic