Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

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

 
Gnanasekaran Sakthivel
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
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66141
141
IntelliJ IDE Java jQuery Mac Mac OS X
  • 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.
 
Stefan Evans
Bartender
Posts: 1836
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
Author and ninkuma
Marshal
Posts: 66141
141
IntelliJ IDE Java jQuery Mac Mac OS X
  • 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
Author and ninkuma
Marshal
Posts: 66141
141
IntelliJ IDE Java jQuery Mac Mac OS X
  • 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
Author and ninkuma
Marshal
Posts: 66141
141
IntelliJ IDE Java jQuery Mac Mac OS X
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!