• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
  • Knute Snortum
Sheriffs:
  • Liutauras Vilda
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Joe Ess
  • salvin francis
  • fred rosenberger

dynamic image as part of a big page with lots of other stuff

 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a jsp that includes lots of other jsp-s. Now one such included jsp (renders a nice html table panel as other similar ones also do, which) has to display an image. This image dynamically will come from documentum as a document object. From that document object, i can get document.getBData() which gives byte array or i can get document.getFile() which gives java.io.File.
In my case this is a (jpeg) image file

Initially, i created a servlet and i tried doing

where src attribute of the img tag point to the servlet url
or using


Now the former option did not do anything...i mean it is not getting to the servlet.. i might be missing some simple knowledge here...
Latter option reaches the servlet...as i knew it, it hits this illegalstateexception. i could not find a way to properly do it. can someone help me?

Another way to ask the question is: Can we have a servlet to process part of the response? or Can we render images from database CLOB type?

All the examples I see online are to render an image as a total response...

My current servlet code...


thanks guys
 
Marshal
Posts: 67344
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Gnanasekaran Sakthivel wrote:where src attribute of the img tag point to the servlet url


This is the correct approach.

or using


This is not.

Now the former option did not do anything...i mean it is not getting to the servlet..


Which likely means the URL in the <img> tag is incorrect.
 
Bartender
Posts: 1845
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And what is most likely wrong is that you are omitting the context path for your web application.

 
Bear Bibeault
Marshal
Posts: 67344
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A small correction:


 
Gnanasekaran Sakthivel
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks bear...
can we have relative path to servlet in image tag's src attribute.. or it has to be a proper request starting with "http://..."

suppose i have a servlet deployed at url /myImageServlet
can i not just say img src="/myImageServlet" ?

thanks
 
Bear Bibeault
Marshal
Posts: 67344
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We just showed you how it is done. URLs for servlets in the same web app should begin with the context path. Anything else might work, but will be fragile and easily broken.
 
Gnanasekaran Sakthivel
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It (context-ed path) worked. Thanks a lot.
 
Bear Bibeault
Marshal
Posts: 67344
173
Mac Mac OS X IntelliJ IDE jQuery Java
 
All of the world's problems can be solved in a garden - Geoff Lawton. Tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!