• 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

display image and text both on jsp page

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi i want to display employ profile with image. my code execute correct but display only image which is retrieve from database. How i can display text and image both together on jsp page as profile .
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A JSP creates an HTML page to send to the client.

So the real question is: how does one show both text and images on an HTML page.

And I bet you already know the answer.
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm not sure I understand the question, but without any JSP code to look at it's impossible to help.

Moving to (more) appropriate forum; it may get moved again.
 
Lalit Chattar
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Bear Bibeault wrote:A JSP creates an HTML page to send to the client.

So the real question is: how does one show both text and images on an HTML page.

And I bet you already know the answer.




Thank you sir

but my image is retrieved from database as a binary stream and other information also from database.
and i want to show both on page.

for image i use response.getOutputStream.write(); function but it show only image.
i want display both binary stream as image and text..

Thank you
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The "other information" would be part of the JSP/HTML page. Images are added to HTML pages via <img> tags, they're not part of the page itself. So, it's easy to display both text and images on the same page, but it's impossible to have both be part of the same "stream"; there'll be separate requests for the images.
 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
actullay you need to get image from database using servlet with params
for exampple
fetchimage is a servlet to get a desired image send it with parametre
ex:fetchimage?name=amrishwa and specify
 
Ranch Hand
Posts: 806
MySQL Database Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Lalit, you cannot get two different content types in one response, my suggestion is to use inline frames and get two different responses, otherwise you have to store the image in your tomcat installation directory under your application, then you can access the image using <img> tag.

I know these two alternatives only, if there is another alternative please tell me so that I can learn more.

Have a nice day.
 
Ranch Hand
Posts: 650
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

anusha chaitanya wrote:Hi Lalit, you cannot get two different content types in one response, my suggestion is to use inline frames and get two different responses, otherwise you have to store the image in your tomcat installation directory under your application, then you can access the image using <img> tag.

I know these two alternatives only, if there is another alternative please tell me so that I can learn more.

Have a nice day.


How about using an Image servlet to serve the image, and just embedding the URL to the servlet in an <img> tag in the generated HTML as others have said?
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No frames or iframes are necessary. Sheesh. Just use the image tag like it's supposed to be used.
 
chaitanya karthikk
Ranch Hand
Posts: 806
MySQL Database Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Mark E Hansen wrote:
How about using an Image servlet to serve the image, and just embedding the URL to the servlet in an <img> tag in the generated HTML as others have said?



Hi Hansen, can you explain it clearly, I can learn a new technique, just explain the method.

Thank you in advance.
 
Mark E Hansen
Ranch Hand
Posts: 650
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Just look for how to do two things:

1. How to use an <img ...> tag in an HTML page;

2. How to create an image servlet. Just do a search for Image Servlet, and you should find several examples.

The idea is that your JSP page will generate the <img> tag, where the URL will invoke your image servlet, which will serve your image.

Good luck.
 
chaitanya karthikk
Ranch Hand
Posts: 806
MySQL Database Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks a lot Mark.
reply
    Bookmark Topic Watch Topic
  • New Topic